Arcane  v4.1.9.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
AbstractArray.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* AbstractArray.h (C) 2000-2026 */
9/* */
10/* Classe de base des tableaux. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_COMMON_ABSTRACTARRAY_H
13#define ARCCORE_COMMON_ABSTRACTARRAY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/Span.h"
18
19#include "arccore/common/ArrayTraits.h"
20#include "arccore/common/ArrayMetaData.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
46class ARCCORE_COMMON_EXPORT AbstractArrayBase
47{
48 public:
49
50 AbstractArrayBase()
51 {
52 m_md = &m_meta_data;
53 }
54 virtual ~AbstractArrayBase() = default;
55
56 public:
58 IMemoryAllocator* allocator() const
59 {
60 return m_md->allocation_options.allocator();
61 }
62 MemoryAllocationOptions allocationOptions() const
63 {
64 return m_md->allocation_options;
65 }
71 void setDebugName(const String& name);
73 String debugName() const;
74
75 protected:
76
77 ArrayMetaData* m_md = nullptr;
78 ArrayMetaData m_meta_data;
79
80 protected:
81
83 static constexpr RunQueue* _nullRunQueue() { return nullptr; }
84
91 virtual bool _isUseOwnMetaData() const
92 {
93 return true;
94 }
95
96 protected:
97
98 void _swapMetaData(AbstractArrayBase& rhs)
99 {
100 std::swap(m_md, rhs.m_md);
101 std::swap(m_meta_data, rhs.m_meta_data);
102 _checkSetUseOwnMetaData();
103 rhs._checkSetUseOwnMetaData();
104 }
105
106 void _copyMetaData(const AbstractArrayBase& rhs)
107 {
108 // Déplace les meta-données
109 // Attention si on utilise m_meta_data alors il
110 // faut positionner m_md pour qu'il pointe vers notre propre m_meta_data.
111 m_meta_data = rhs.m_meta_data;
112 m_md = rhs.m_md;
113 _checkSetUseOwnMetaData();
114 }
115
116 void _allocateMetaData()
117 {
118#ifdef ARCCORE_CHECK
119 if (m_md->is_not_null)
120 ArrayMetaData::throwNullExpected();
121#endif
122 if (_isUseOwnMetaData()) {
123 m_meta_data = ArrayMetaData();
124 m_md = &m_meta_data;
125 }
126 else {
127 m_md = new ArrayMetaData();
128 m_md->is_allocated_by_new = true;
129 }
130 m_md->is_not_null = true;
131 }
132
133 void _deallocateMetaData(ArrayMetaData* md)
134 {
135 if (md->is_allocated_by_new)
136 delete md;
137 else
138 *md = ArrayMetaData();
139 }
140
141 void _checkValidSharedArray()
142 {
143#ifdef ARCCORE_CHECK
144 if (m_md->is_not_null && !m_md->is_allocated_by_new)
145 ArrayMetaData::throwInvalidMetaDataForSharedArray();
146#endif
147 }
148
149 private:
150
151 void _checkSetUseOwnMetaData()
152 {
153 if (!m_md->is_allocated_by_new)
154 m_md = &m_meta_data;
155 }
156};
157
158/*---------------------------------------------------------------------------*/
159/*---------------------------------------------------------------------------*/
167template <typename T>
169: public AbstractArrayBase
170{
171 public:
172
173 typedef typename ArrayTraits<T>::ConstReferenceType ConstReferenceType;
174 typedef typename ArrayTraits<T>::IsPODType IsPODType;
175 typedef AbstractArray<T> ThatClassType;
176 using TrueImpl = T;
177
178 public:
179
181 typedef T value_type;
185 typedef const value_type* const_pointer;
193 typedef ConstReferenceType const_reference;
197 typedef ptrdiff_t difference_type;
198
199 typedef std::reverse_iterator<iterator> reverse_iterator;
200 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
201
202 protected:
203
206 {
207 }
208
209 AbstractArray(ThatClassType&& rhs) ARCCORE_NOEXCEPT
210 : m_ptr(rhs.m_ptr)
211 {
212 _copyMetaData(rhs);
213 rhs._reset();
214 }
215
216 ~AbstractArray() override
217 {
218 --m_md->nb_ref;
220 }
221
222 public:
223
224 AbstractArray(const AbstractArray<T>& rhs) = delete;
225 AbstractArray<T>& operator=(const AbstractArray<T>& rhs) = delete;
226
227 protected:
228
229 static constexpr Int64 typeSize() { return static_cast<Int64>(sizeof(T)); }
230 AllocatedMemoryInfo _currentMemoryInfo() const
231 {
232 return AllocatedMemoryInfo(m_ptr, m_md->size * typeSize(), m_md->capacity * typeSize());
233 }
234
235 protected:
236
242 void _initFromSpan(const Span<const T>& view)
243 {
244 Int64 asize = view.size();
245 if (asize != 0) {
246 _internalAllocate(asize, _nullRunQueue());
247 _createRange(0, asize, view.data());
248 m_md->size = asize;
249 }
250 }
251
262 void* pre_allocated_buffer = nullptr)
263 {
264 _directFirstAllocateWithAllocator(acapacity, o, pre_allocated_buffer);
265 }
266
267 public:
268
270 void dispose()
271 {
272 _destroy();
273 MemoryAllocationOptions options(m_md->allocation_options);
274 _internalDeallocate();
275 _setToSharedNull();
276 // Si on a un allocateur spécifique, il faut allouer un
277 // bloc pour conserver cette information.
278 if (options.allocator() != m_md->_allocator())
281 }
282
283 public:
284
285 operator ConstArrayView<T>() const
286 {
287 return ConstArrayView<T>(ARCCORE_CAST_SMALL_SIZE(size()), m_ptr);
288 }
289 operator Span<const T>() const
290 {
291 return Span<const T>(m_ptr, m_md->size);
292 }
293 operator SmallSpan<const T>() const
294 {
295 return SmallSpan<const T>(m_ptr, ARCCORE_CAST_SMALL_SIZE(size()));
296 }
297
298 public:
299
301 Integer size() const { return ARCCORE_CAST_SMALL_SIZE(m_md->size); }
303 Integer length() const { return ARCCORE_CAST_SMALL_SIZE(m_md->size); }
305 Integer capacity() const { return ARCCORE_CAST_SMALL_SIZE(m_md->capacity); }
307 Int64 largeSize() const { return m_md->size; }
309 Int64 largeLength() const { return m_md->size; }
311 Int64 largeCapacity() const { return m_md->capacity; }
313 bool empty() const { return m_md->size == 0; }
315 bool contains(ConstReferenceType v) const
316 {
317 const T* ptr = m_ptr;
318 for (Int64 i = 0, n = m_md->size; i < n; ++i) {
319 if (ptr[i] == v)
320 return true;
321 }
322 return false;
323 }
324
325 public:
326
328 ConstReferenceType operator[](Int64 i) const
329 {
330 ARCCORE_CHECK_AT(i, m_md->size);
331 return m_ptr[i];
332 }
333
334 ConstReferenceType operator()(Int64 i) const
335 {
336 ARCCORE_CHECK_AT(i, m_md->size);
337 return m_ptr[i];
338 }
339
340 public:
341
344 {
345 m_md->_setMemoryLocationHint(new_hint, m_ptr, sizeof(T));
346 }
347
355 {
356 m_md->m_host_device_memory_location = location;
357 }
358
361 {
362 return m_md->m_host_device_memory_location;
363 }
364
365 public:
366
367 friend bool operator==(const AbstractArray<T>& rhs, const AbstractArray<T>& lhs)
368 {
369 return operator==(Span<const T>(rhs), Span<const T>(lhs));
370 }
371
372 friend bool operator!=(const AbstractArray<T>& rhs, const AbstractArray<T>& lhs)
373 {
374 return !(rhs == lhs);
375 }
376
377 friend bool operator==(const AbstractArray<T>& rhs, const Span<const T>& lhs)
378 {
379 return operator==(Span<const T>(rhs), lhs);
380 }
381
382 friend bool operator!=(const AbstractArray<T>& rhs, const Span<const T>& lhs)
383 {
384 return !(rhs == lhs);
385 }
386
387 friend bool operator==(const Span<const T>& rhs, const AbstractArray<T>& lhs)
388 {
389 return operator==(rhs, Span<const T>(lhs));
390 }
391
392 friend bool operator!=(const Span<const T>& rhs, const AbstractArray<T>& lhs)
393 {
394 return !(rhs == lhs);
395 }
396
397 friend std::ostream& operator<<(std::ostream& o, const AbstractArray<T>& val)
398 {
399 o << Span<const T>(val);
400 return o;
401 }
402
403 private:
404
405 using AbstractArrayBase::m_meta_data;
406
407 protected:
408
409 // NOTE: Ces deux champs sont utilisés pour l'affichage TTF de totalview.
410 // Si on modifie leur ordre il faut mettre à jour la partie correspondante
411 // dans l'afficheur totalview de Arcane.
412 T* m_ptr = nullptr;
413
414 protected:
415
417 void _reserve(Int64 new_capacity)
418 {
419 if (new_capacity <= m_md->capacity) {
420 // Dans le cas d'un allocateur collectif, on doit quand même faire un
421 // réalloc (à l'allocateur de gérer l'optimisation).
422 if (m_meta_data.is_collective_allocator) {
423 _internalRealloc(m_md->capacity, false);
424 }
425 return;
426 }
427 _internalRealloc(new_capacity, false);
428 }
429
434 void _internalRealloc(Int64 new_capacity, bool compute_capacity, RunQueue* queue = nullptr)
435 {
436 // Remarque : Pour la mémoire partagée, si un des ptr est nullptr, alors
437 // il l'est pour tous les processus.
438 if (_isSharedNull()) {
439 if (new_capacity != 0 || m_meta_data.is_collective_allocator)
440 _internalAllocate(new_capacity, queue);
441 return;
442 }
443
444 Int64 acapacity = new_capacity;
445 if (compute_capacity) {
446 acapacity = m_md->capacity;
447 //std::cout << " REALLOC: want=" << wanted_size << " current_capacity=" << capacity << '\n';
448 while (new_capacity > acapacity)
449 acapacity = (acapacity == 0) ? 4 : (acapacity + 1 + acapacity / 2);
450 //std::cout << " REALLOC: want=" << wanted_size << " new_capacity=" << capacity << '\n';
451 }
452 // Si la nouvelle capacité est inférieure à la courante, ne fait rien
453 // (sauf pour un allocateur collectif).
454 if (acapacity <= m_md->capacity) {
455 if (m_meta_data.is_collective_allocator) {
456 _internalReallocate(m_md->capacity, queue);
457 }
458 return;
459 }
460 _internalReallocate(acapacity, queue);
461 }
462
463 void _internalReallocate(Int64 new_capacity, RunQueue* queue)
464 {
465 if constexpr (std::is_trivially_copyable_v<T>) {
466 T* old_ptr = m_ptr;
467 Int64 old_capacity = m_md->capacity;
468 _directReAllocate(new_capacity, queue);
469 bool update = (new_capacity < old_capacity) || (m_ptr != old_ptr);
470 if (update) {
472 }
473 }
474 else {
475 T* old_ptr = m_ptr;
476 ArrayMetaData* old_md = m_md;
477 AllocatedMemoryInfo old_mem_info = _currentMemoryInfo();
478 Int64 old_size = m_md->size;
479 _directAllocate(new_capacity, queue);
480 if (m_ptr != old_ptr) {
481 for (Int64 i = 0; i < old_size; ++i) {
482 new (m_ptr + i) T(old_ptr[i]);
483 old_ptr[i].~T();
484 }
485 m_md->nb_ref = old_md->nb_ref;
486 m_md->_deallocate(old_mem_info, queue);
488 }
489 }
490 }
491
492 // Libère la mémoire
493 void _internalDeallocate(RunQueue* queue = nullptr)
494 {
495 // Remarque : Pour la mémoire partagée, si un des ptr est nullptr, alors
496 // il l'est pour tous les processus.
497 if (!_isSharedNull())
498 m_md->_deallocate(_currentMemoryInfo(), queue);
499 if (m_md->is_not_null)
500 _deallocateMetaData(m_md);
501 }
502 void _internalAllocate(Int64 new_capacity, RunQueue* queue)
503 {
504 _directAllocate(new_capacity, queue);
505 m_md->nb_ref = _getNbRef();
507 }
508
509 void _copyFromMemory(const T* source)
510 {
511 m_md->_copyFromMemory(m_ptr, source, sizeof(T), _nullRunQueue());
512 }
513
514 private:
515
525 void* pre_allocated_buffer = nullptr)
526 {
527 IMemoryAllocator* wanted_allocator = options.allocator();
528 if (!wanted_allocator) {
529 wanted_allocator = ArrayMetaData::_defaultAllocator();
530 options.setAllocator(wanted_allocator);
531 }
532 _allocateMetaData();
533 m_md->allocation_options = options;
534 if (new_capacity > 0) {
535 if (!pre_allocated_buffer)
536 _allocateMP(new_capacity, nullptr);
537 else
538 _setMPCast(pre_allocated_buffer);
539 }
540 m_md->nb_ref = _getNbRef();
541 m_md->size = 0;
543 }
544
545 void _directAllocate(Int64 new_capacity, RunQueue* queue)
546 {
547 if (!m_md->is_not_null)
548 _allocateMetaData();
549 _allocateMP(new_capacity, queue);
550 }
551
552 void _allocateMP(Int64 new_capacity, RunQueue* queue)
553 {
554 _setMPCast(m_md->_allocate(new_capacity, typeSize(), queue));
555 }
556
557 void _directReAllocate(Int64 new_capacity, RunQueue* queue)
558 {
559 _setMPCast(m_md->_reallocate(_currentMemoryInfo(), new_capacity, typeSize(), queue));
560 }
561
562 public:
563
564 void changeAllocator(const MemoryAllocationOptions& options, RunQueue* queue)
565 {
566 _setMPCast(m_md->_changeAllocator(options, _currentMemoryInfo(), typeSize(), queue));
568 }
569
570 void changeAllocator(const MemoryAllocationOptions& options)
571 {
572 _setMPCast(m_md->_changeAllocator(options, _currentMemoryInfo(), typeSize(), _nullRunQueue()));
574 }
575
576 public:
577
578 void printInfos(std::ostream& o)
579 {
580 o << " Infos: size=" << m_md->size << " capacity=" << m_md->capacity << '\n';
581 }
582
583 protected:
584
586 virtual void _updateReferences()
587 {
588 }
589
591 {
592 return 1;
593 }
594
595 void _addRange(ConstReferenceType val, Int64 n)
596 {
597 Int64 s = m_md->size;
598 if ((s + n) > m_md->capacity)
599 _internalRealloc(s + n, true);
600 for (Int64 i = 0; i < n; ++i)
601 new (m_ptr + s + i) T(val);
602 m_md->size += n;
603 }
604
607 {
608 Int64 n = val.size();
609 const T* ptr = val.data();
610 Int64 s = m_md->size;
611 if ((s + n) > m_md->capacity)
612 _internalRealloc(s + n, true);
613 _createRange(s, s + n, ptr);
614 m_md->size += n;
615 }
616
619 {
620 if (m_md->nb_ref == 0) {
621 _destroy();
622 _internalDeallocate(_nullRunQueue());
623 }
624 }
625 void _destroy()
626 {
627 _destroyRange(0, m_md->size, IsPODType());
628 }
629 void _destroyRange(Int64, Int64, TrueType)
630 {
631 // Rien à faire pour un type POD.
632 }
633 void _destroyRange(Int64 abegin, Int64 aend, FalseType)
634 {
635 if (abegin < 0)
636 abegin = 0;
637 for (Int64 i = abegin; i < aend; ++i)
638 m_ptr[i].~T();
639 }
640 void _createRangeDefault(Int64, Int64, TrueType)
641 {
642 }
643 void _createRangeDefault(Int64 abegin, Int64 aend, FalseType)
644 {
645 if (abegin < 0)
646 abegin = 0;
647 for (Int64 i = abegin; i < aend; ++i)
648 new (m_ptr + i) T();
649 }
650 void _createRange(Int64 abegin, Int64 aend, ConstReferenceType value, TrueType)
651 {
652 if (abegin < 0)
653 abegin = 0;
654 for (Int64 i = abegin; i < aend; ++i)
655 m_ptr[i] = value;
656 }
657 void _createRange(Int64 abegin, Int64 aend, ConstReferenceType value, FalseType)
658 {
659 if (abegin < 0)
660 abegin = 0;
661 for (Int64 i = abegin; i < aend; ++i)
662 new (m_ptr + i) T(value);
663 }
664 void _createRange(Int64 abegin, Int64 aend, const T* values)
665 {
666 if (abegin < 0)
667 abegin = 0;
668 for (Int64 i = abegin; i < aend; ++i) {
669 new (m_ptr + i) T(*values);
670 ++values;
671 }
672 }
673 void _fill(ConstReferenceType value)
674 {
675 for (Int64 i = 0, n = size(); i < n; ++i)
676 m_ptr[i] = value;
677 }
678 void _clone(const ThatClassType& orig_array)
679 {
680 Int64 that_size = orig_array.size();
681 _internalAllocate(that_size, _nullRunQueue());
682 m_md->size = that_size;
683 m_md->dim1_size = orig_array.m_md->dim1_size;
684 m_md->dim2_size = orig_array.m_md->dim2_size;
685 _createRange(0, that_size, orig_array.m_ptr);
686 }
687 template <typename PodType>
688 void _resizeHelper(Int64 s, PodType pod_type, RunQueue* queue)
689 {
690 if (s < 0)
691 s = 0;
692 if (s > m_md->size) {
693 this->_internalRealloc(s, false, queue);
694 this->_createRangeDefault(m_md->size, s, pod_type);
695 }
696 else {
697 this->_destroyRange(s, m_md->size, pod_type);
698 if (m_meta_data.is_collective_allocator) {
699 this->_internalRealloc(s, false, queue);
700 }
701 }
702 m_md->size = s;
703 }
704 void _resize(Int64 s)
705 {
706 _resizeHelper(s, IsPODType(), _nullRunQueue());
707 }
709 void _resizeNoInit(Int64 s, RunQueue* queue = nullptr)
710 {
711 _resizeHelper(s, TrueType{}, queue);
712 }
713 void _clear()
714 {
715 this->_destroyRange(0, m_md->size, IsPODType());
716 m_md->size = 0;
717 }
719 void _resize(Int64 s, ConstReferenceType value)
720 {
721 if (s < 0)
722 s = 0;
723 if (s > m_md->size) {
724 this->_internalRealloc(s, false);
725 this->_createRange(m_md->size, s, value, IsPODType());
726 }
727 else {
728 this->_destroyRange(s, m_md->size, IsPODType());
729 if (m_meta_data.is_collective_allocator) {
730 this->_internalRealloc(s, false);
731 }
732 }
733 m_md->size = s;
734 }
735 void _copy(const T* rhs_begin, TrueType)
736 {
737 _copyFromMemory(rhs_begin);
738 }
739 void _copy(const T* rhs_begin, FalseType)
740 {
741 for (Int64 i = 0, n = m_md->size; i < n; ++i)
742 m_ptr[i] = rhs_begin[i];
743 }
744 void _copy(const T* rhs_begin)
745 {
746 _copy(rhs_begin, IsPODType());
747 }
748
758 {
759 const T* rhs_begin = rhs.data();
760 Int64 rhs_size = rhs.size();
761 const Int64 current_size = m_md->size;
762 T* abegin = m_ptr;
763 // Vérifie que \a rhs n'est pas un élément à l'intérieur de ce tableau
764 if (abegin >= rhs_begin && abegin < (rhs_begin + rhs_size))
765 ArrayMetaData::overlapError(abegin, m_md->size, rhs_begin, rhs_size);
766
767 if (rhs_size > current_size) {
768 this->_internalRealloc(rhs_size, false);
769 // Crée les nouveaux éléments
770 this->_createRange(m_md->size, rhs_size, rhs_begin + current_size);
771 // Copie les éléments déjà existant
772 _copy(rhs_begin);
773 m_md->size = rhs_size;
774 }
775 else {
776 this->_destroyRange(rhs_size, current_size, IsPODType{});
777 m_md->size = rhs_size;
778 _copy(rhs_begin);
779 }
780 }
781
789 void _move(ThatClassType& rhs) ARCCORE_NOEXCEPT
790 {
791 if (&rhs == this)
792 return;
793
794 // Comme il n'y a qu'une seule référence sur le tableau actuel, on peut
795 // directement libérer la mémoire.
796 _destroy();
797 _internalDeallocate(_nullRunQueue());
798
799 _setMP(rhs.m_ptr);
800
801 _copyMetaData(rhs);
802
803 // Indique que \a rhs est vide.
804 rhs._reset();
805 }
806
813 void _swap(ThatClassType& rhs) ARCCORE_NOEXCEPT
814 {
815 std::swap(m_ptr, rhs.m_ptr);
816 _swapMetaData(rhs);
817 }
818
819 void _shrink()
820 {
821 _shrink(size());
822 }
823
824 // Réalloue la mémoire pour avoir une capacité proche de \a new_capacity
825 void _shrink(Int64 new_capacity)
826 {
827 if (_isSharedNull())
828 return;
829 // On n'augmente pas la capacité avec cette méthode
830 if (new_capacity > this->capacity())
831 return;
832 if (new_capacity < 4)
833 new_capacity = 4;
834 _internalReallocate(new_capacity, _nullRunQueue());
835 }
836
842 void _reset()
843 {
844 _setToSharedNull();
845 }
846
847 constexpr Integer _clampSizeOffet(Int64 offset, Int32 asize) const
848 {
849 Int64 max_size = m_md->size - offset;
850 if (asize > max_size)
851 // On est certain de ne pas dépasser 32 bits car on est inférieur à asize.
852 asize = static_cast<Integer>(max_size);
853 return asize;
854 }
855
856 // Uniquement pour UniqueArray et UniqueArray2
857 void _assignFromArray(const AbstractArray<T>& rhs)
858 {
859 if (&rhs == this)
860 return;
861 Span<const T> rhs_span(rhs);
862 if (rhs.allocator() == this->allocator()) {
863 _resizeAndCopyView(rhs_span);
864 }
865 else {
866 _destroy();
867 _internalDeallocate(_nullRunQueue());
868 _reset();
869 _initFromAllocator(rhs.allocationOptions(), 0);
870 _initFromSpan(rhs_span);
871 }
872 }
873
874 protected:
875
876 void _setMP(TrueImpl* new_mp)
877 {
878 m_ptr = new_mp;
879 }
880
881 void _setMP2(TrueImpl* new_mp, ArrayMetaData* new_md)
882 {
883 _setMP(new_mp);
884 // Il ne faut garder le nouveau m_md que s'il est alloué
885 // sinon on risque d'avoir des références sur des objets temporaires
886 m_md = new_md;
887 if (!m_md->is_allocated_by_new)
888 m_md = &m_meta_data;
889 }
890
891 bool _isSharedNull()
892 {
893 return m_ptr == nullptr;
894 }
895
896 private:
897
898 void _setToSharedNull()
899 {
900 m_ptr = nullptr;
901 m_meta_data = ArrayMetaData();
902 m_md = &m_meta_data;
903 }
904 void _setMPCast(void* p)
905 {
906 _setMP(reinterpret_cast<TrueImpl*>(p));
907 }
908};
909
910/*---------------------------------------------------------------------------*/
911/*---------------------------------------------------------------------------*/
912
913} // namespace Arcane
914
915/*---------------------------------------------------------------------------*/
916/*---------------------------------------------------------------------------*/
917
918#endif
Types et fonctions associés aux classes SpanImpl, SmallSpan and Span.
Classe de base interne pour les tableaux.
static constexpr RunQueue * _nullRunQueue()
Méthode explicite pour une RunQueue nulle.
virtual bool _isUseOwnMetaData() const
Indique si m_md fait référence à m_meta_data.
Classe abstraite de base d'un vecteur.
void _addRange(ConstReferenceType val, Int64 n)
Ajoute n élément de valeur val à la fin du tableau.
Integer capacity() const
Capacité (nombre d'éléments alloués) du vecteur.
void _addRange(Span< const T > val)
Ajoute n élément de valeur val à la fin du tableau.
void _internalSetHostDeviceMemoryLocation(eHostDeviceMemoryLocation location)
Positionne l'emplacement physique de la zone mémoire.
virtual void _updateReferences()
Mise à jour des références.
void _checkFreeMemory()
Détruit l'instance si plus personne ne la référence.
ConstReferenceType operator[](Int64 i) const
Elément d'indice i.
void dispose()
Libère la mémoire utilisée par le tableau.
AbstractArray()
Construit un vecteur vide avec l'allocateur par défaut.
Integer size() const
Nombre d'éléments du vecteur.
void _initFromSpan(const Span< const T > &view)
Initialise le tableau avec la vue view.
void _move(ThatClassType &rhs) ARCCORE_NOEXCEPT
Implémente l'opérateur d'assignement par déplacement.
void _initFromAllocator(MemoryAllocationOptions o, Int64 acapacity, void *pre_allocated_buffer=nullptr)
Construit un vecteur vide avec un allocateur spécifique a.
ArrayIterator< pointer > iterator
void _resize(Int64 s, ConstReferenceType value)
Redimensionne et remplit les nouvelles valeurs avec value.
void setMemoryLocationHint(eMemoryLocationHint new_hint)
Modifie les informations sur la localisation mémoire.
bool empty() const
Capacité (nombre d'éléments alloués) du vecteur.
eHostDeviceMemoryLocation hostDeviceMemoryLocation() const
Positionne l'emplacement physique de la zone mémoire.
Int64 largeSize() const
Nombre d'éléments du vecteur (en 64 bits)
bool contains(ConstReferenceType v) const
Vrai si le tableau contient l'élément de valeur v.
Int64 largeCapacity() const
Capacité (nombre d'éléments alloués) du vecteur (en 64 bits)
Int64 largeLength() const
Nombre d'éléments du vecteur (en 64 bits)
void _directFirstAllocateWithAllocator(Int64 new_capacity, MemoryAllocationOptions options, void *pre_allocated_buffer=nullptr)
Effectue la première allocation.
void _internalRealloc(Int64 new_capacity, bool compute_capacity, RunQueue *queue=nullptr)
Réalloue le tableau pour une nouvelle capacité égale à new_capacity.
void _reserve(Int64 new_capacity)
Réserve le mémoire pour new_capacity éléments.
void _resizeAndCopyView(Span< const T > rhs)
Redimensionne l'instance et recopie les valeurs de rhs.
virtual Integer _getNbRef()
Mise à jour des références.
ArrayIterator< const_pointer > const_iterator
void _resizeNoInit(Int64 s, RunQueue *queue=nullptr)
Redimensionne sans initialiser les nouvelles valeurs.
AbstractArray(ThatClassType &&rhs) ARCCORE_NOEXCEPT
Constructeur par déplacement. Ne doit être utilisé que par UniqueArray.
void _swap(ThatClassType &rhs) ARCCORE_NOEXCEPT
Échange les valeurs de l'instance avec celles de rhs.
ConstReferenceType operator()(Int64 i) const
Elément d'indice i.
void _reset()
Réinitialise le tableau à un tableau vide.
Integer length() const
Nombre d'éléments du vecteur.
String debugName() const
void setDebugName(const String &name)
Itérateur sur les classes tableau de Arccore.
Meta-Données des tableaux.
bool is_not_null
Indique si cette instance n'est pas l'instance nulle (partagée par tous les SharedArray)
Int64 size
Nombre d'éléments du tableau (pour les tableaux 1D)
Int64 capacity
Nombre d'éléments alloués.
Int32 nb_ref
Nombre de références sur l'instance.
bool is_allocated_by_new
Indique is cette instance a été allouée par l'opérateur new.
Vue constante d'un tableau de type T.
Interface d'un allocateur pour la mémoire.
constexpr __host__ __device__ pointer data() const noexcept
Pointeur sur le début de la vue.
Definition Span.h:537
constexpr __host__ __device__ SizeType size() const noexcept
Retourne la taille du tableau.
Definition Span.h:325
Vue d'un tableau d'éléments de type T.
Definition Span.h:633
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
eMemoryLocationHint
Indices sur la localisation mémoire attendue.
eHostDeviceMemoryLocation
Localisation physique d'une adresse mémoire.
std::int32_t Int32
Type entier signé sur 32 bits.
Structure équivalente à la valeur booléenne vrai.