Arcane  4.2.1.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:
57
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 void printInfos(std::ostream& o);
76
77 protected:
78
79 ArrayMetaData* m_md = nullptr;
80 ArrayMetaData m_meta_data;
81
82 protected:
83
85 static constexpr RunQueue* _nullRunQueue() { return nullptr; }
86
93 virtual bool _isUseOwnMetaData() const
94 {
95 return true;
96 }
97
98 protected:
99
100 void _swapMetaData(AbstractArrayBase& rhs)
101 {
102 std::swap(m_md, rhs.m_md);
103 std::swap(m_meta_data, rhs.m_meta_data);
104 _checkSetUseOwnMetaData();
105 rhs._checkSetUseOwnMetaData();
106 }
107
108 void _copyMetaData(const AbstractArrayBase& rhs)
109 {
110 // Déplace les meta-données
111 // Attention si on utilise m_meta_data alors il
112 // faut positionner m_md pour qu'il pointe vers notre propre m_meta_data.
113 m_meta_data = rhs.m_meta_data;
114 m_md = rhs.m_md;
115 _checkSetUseOwnMetaData();
116 }
117
118 void _allocateMetaData()
119 {
120#ifdef ARCCORE_CHECK
121 if (m_md->is_not_null)
122 ArrayMetaData::throwNullExpected();
123#endif
124 if (_isUseOwnMetaData()) {
125 m_meta_data = ArrayMetaData();
126 m_md = &m_meta_data;
127 }
128 else {
129 m_md = new ArrayMetaData();
130 m_md->is_allocated_by_new = true;
131 }
132 m_md->is_not_null = true;
133 }
134
135 void _deallocateMetaData(ArrayMetaData* md)
136 {
137 if (md->is_allocated_by_new)
138 delete md;
139 else
140 *md = ArrayMetaData();
141 }
142
143 void _checkValidSharedArray()
144 {
145#ifdef ARCCORE_CHECK
146 if (m_md->is_not_null && !m_md->is_allocated_by_new)
147 ArrayMetaData::throwInvalidMetaDataForSharedArray();
148#endif
149 }
150
151 private:
152
153 void _checkSetUseOwnMetaData()
154 {
155 if (!m_md->is_allocated_by_new)
156 m_md = &m_meta_data;
157 }
158};
159
160/*---------------------------------------------------------------------------*/
161/*---------------------------------------------------------------------------*/
162
170template <typename T>
172: public AbstractArrayBase
173{
174 public:
175
176 typedef typename ArrayTraits<T>::ConstReferenceType ConstReferenceType;
177 typedef typename ArrayTraits<T>::IsPODType IsPODType;
178 typedef AbstractArray<T> ThatClassType;
179 using TrueImpl = T;
180
181 public:
182
184 typedef T value_type;
188 typedef const value_type* const_pointer;
196 typedef ConstReferenceType const_reference;
200 typedef ptrdiff_t difference_type;
201
202 typedef std::reverse_iterator<iterator> reverse_iterator;
203 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
204
205 protected:
206
209 {
210 }
211
212 AbstractArray(ThatClassType&& rhs) ARCCORE_NOEXCEPT
213 : m_ptr(rhs.m_ptr)
214 {
215 _copyMetaData(rhs);
216 rhs._reset();
217 }
218
219 ~AbstractArray() override
220 {
221 --m_md->nb_ref;
223 }
224
225 public:
226
227 AbstractArray(const AbstractArray<T>& rhs) = delete;
228 AbstractArray<T>& operator=(const AbstractArray<T>& rhs) = delete;
229
230 protected:
231
232 static constexpr Int64 typeSize() { return static_cast<Int64>(sizeof(T)); }
233 AllocatedMemoryInfo _currentMemoryInfo() const
234 {
235 return AllocatedMemoryInfo(m_ptr, m_md->size * typeSize(), m_md->capacity * typeSize());
236 }
237
238 protected:
239
245 void _initFromSpan(const Span<const T>& view)
246 {
247 Int64 asize = view.size();
248 if (asize != 0) {
249 _internalAllocate(asize, _nullRunQueue());
250 _createRange(0, asize, view.data());
251 m_md->size = asize;
252 }
253 }
254
265 void* pre_allocated_buffer = nullptr)
266 {
267 _directFirstAllocateWithAllocator(acapacity, o, pre_allocated_buffer);
268 }
269
270 public:
271
273 void dispose()
274 {
275 _destroy();
276 MemoryAllocationOptions options(m_md->allocation_options);
277 _internalDeallocate();
278 _setToSharedNull();
279 // Si on a un allocateur spécifique, il faut allouer un
280 // bloc pour conserver cette information.
281 if (options.allocator() != m_md->_allocator())
284 }
285
286 public:
287
288 operator ConstArrayView<T>() const
289 {
290 return ConstArrayView<T>(ARCCORE_CAST_SMALL_SIZE(size()), m_ptr);
291 }
292 operator Span<const T>() const
293 {
294 return Span<const T>(m_ptr, m_md->size);
295 }
296 operator SmallSpan<const T>() const
297 {
298 return SmallSpan<const T>(m_ptr, ARCCORE_CAST_SMALL_SIZE(size()));
299 }
300
301 public:
302
304 Integer size() const { return ARCCORE_CAST_SMALL_SIZE(m_md->size); }
306 Integer length() const { return ARCCORE_CAST_SMALL_SIZE(m_md->size); }
308 Integer capacity() const { return ARCCORE_CAST_SMALL_SIZE(m_md->capacity); }
310 Int64 largeSize() const { return m_md->size; }
312 Int64 largeLength() const { return m_md->size; }
314 Int64 largeCapacity() const { return m_md->capacity; }
316 bool empty() const { return m_md->size == 0; }
318 bool contains(ConstReferenceType v) const
319 {
320 const T* ptr = m_ptr;
321 for (Int64 i = 0, n = m_md->size; i < n; ++i) {
322 if (ptr[i] == v)
323 return true;
324 }
325 return false;
326 }
327
328 public:
329
331 ConstReferenceType operator[](Int64 i) const
332 {
333 ARCCORE_CHECK_AT(i, m_md->size);
334 return m_ptr[i];
335 }
336
337 ConstReferenceType operator()(Int64 i) const
338 {
339 ARCCORE_CHECK_AT(i, m_md->size);
340 return m_ptr[i];
341 }
342
343 public:
344
347 {
348 m_md->_setMemoryLocationHint(new_hint, m_ptr, sizeof(T));
349 }
350
358 {
359 m_md->m_host_device_memory_location = location;
360 }
361
364 {
365 return m_md->m_host_device_memory_location;
366 }
367
368 public:
369
370 friend bool operator==(const AbstractArray<T>& rhs, const AbstractArray<T>& lhs)
371 {
372 return operator==(Span<const T>(rhs), Span<const T>(lhs));
373 }
374
375 friend bool operator!=(const AbstractArray<T>& rhs, const AbstractArray<T>& lhs)
376 {
377 return !(rhs == lhs);
378 }
379
380 friend bool operator==(const AbstractArray<T>& rhs, const Span<const T>& lhs)
381 {
382 return operator==(Span<const T>(rhs), lhs);
383 }
384
385 friend bool operator!=(const AbstractArray<T>& rhs, const Span<const T>& lhs)
386 {
387 return !(rhs == lhs);
388 }
389
390 friend bool operator==(const Span<const T>& rhs, const AbstractArray<T>& lhs)
391 {
392 return operator==(rhs, Span<const T>(lhs));
393 }
394
395 friend bool operator!=(const Span<const T>& rhs, const AbstractArray<T>& lhs)
396 {
397 return !(rhs == lhs);
398 }
399
400 friend std::ostream& operator<<(std::ostream& o, const AbstractArray<T>& val)
401 {
402 o << Span<const T>(val);
403 return o;
404 }
405
406 private:
407
408 using AbstractArrayBase::m_meta_data;
409
410 protected:
411
412 // NOTE : Ces deux champs sont utilisés pour l'affichage TTF de totalview.
413 // Si on modifie leur ordre il faut mettre à jour la partie correspondante
414 // dans l'afficheur totalview de Arcane.
415 T* m_ptr = nullptr;
416
417 protected:
418
420 void _reserve(Int64 new_capacity)
421 {
422 if (new_capacity <= m_md->capacity) {
423 // Dans le cas d'un allocateur collectif, on doit quand même faire un
424 // réalloc (à l'allocateur de gérer l'optimisation).
425 if (m_meta_data.is_collective_allocator) {
426 _internalRealloc(m_md->capacity, false);
427 }
428 return;
429 }
430 _internalRealloc(new_capacity, false);
431 }
432
437 void _internalRealloc(Int64 new_capacity, bool compute_capacity, RunQueue* queue = nullptr)
438 {
439 // Remarque : Pour la mémoire partagée, si un des ptr est nullptr, alors
440 // il l'est pour tous les processus.
441 if (_isSharedNull()) {
442 if (new_capacity != 0 || m_meta_data.is_collective_allocator)
443 _internalAllocate(new_capacity, queue);
444 return;
445 }
446
447 Int64 acapacity = new_capacity;
448 if (compute_capacity) {
449 acapacity = m_md->capacity;
450 //std::cout << " REALLOC: want=" << wanted_size << " current_capacity=" << capacity << '\n';
451 while (new_capacity > acapacity)
452 acapacity = (acapacity == 0) ? 4 : (acapacity + 1 + acapacity / 2);
453 //std::cout << " REALLOC: want=" << wanted_size << " new_capacity=" << capacity << '\n';
454 }
455 // Si la nouvelle capacité est inférieure à la courante, ne fait rien
456 // (sauf pour un allocateur collectif).
457 if (acapacity <= m_md->capacity) {
458 if (m_meta_data.is_collective_allocator) {
459 _internalReallocate(m_md->capacity, queue);
460 }
461 return;
462 }
463 _internalReallocate(acapacity, queue);
464 }
465
466 void _internalReallocate(Int64 new_capacity, RunQueue* queue)
467 {
468 if constexpr (std::is_trivially_copyable_v<T>) {
469 T* old_ptr = m_ptr;
470 Int64 old_capacity = m_md->capacity;
471 _directReAllocate(new_capacity, queue);
472 bool update = (new_capacity < old_capacity) || (m_ptr != old_ptr);
473 if (update) {
475 }
476 }
477 else {
478 T* old_ptr = m_ptr;
479 ArrayMetaData* old_md = m_md;
480 AllocatedMemoryInfo old_mem_info = _currentMemoryInfo();
481 Int64 old_size = m_md->size;
482 _directAllocate(new_capacity, queue);
483 if (m_ptr != old_ptr) {
484 for (Int64 i = 0; i < old_size; ++i) {
485 new (m_ptr + i) T(old_ptr[i]);
486 old_ptr[i].~T();
487 }
488 m_md->nb_ref = old_md->nb_ref;
489 m_md->_deallocate(old_mem_info, queue);
491 }
492 }
493 }
494
495 // Libère la mémoire
496 void _internalDeallocate(RunQueue* queue = nullptr)
497 {
498 // Remarque : Pour la mémoire partagée, si un des ptr est nullptr, alors
499 // il l'est pour tous les processus.
500 if (!_isSharedNull())
501 m_md->_deallocate(_currentMemoryInfo(), queue);
502 if (m_md->is_not_null)
503 _deallocateMetaData(m_md);
504 }
505 void _internalAllocate(Int64 new_capacity, RunQueue* queue)
506 {
507 _directAllocate(new_capacity, queue);
508 m_md->nb_ref = _getNbRef();
510 }
511
512 void _copyFromMemory(const T* source)
513 {
514 m_md->_copyFromMemory(m_ptr, source, sizeof(T), _nullRunQueue());
515 }
516
517 private:
518
528 void* pre_allocated_buffer = nullptr)
529 {
530 IMemoryAllocator* wanted_allocator = options.allocator();
531 if (!wanted_allocator) {
532 wanted_allocator = ArrayMetaData::_defaultAllocator();
533 options.setAllocator(wanted_allocator);
534 }
535 _allocateMetaData();
536 m_md->allocation_options = options;
537 if (new_capacity > 0) {
538 if (!pre_allocated_buffer)
539 _allocateMP(new_capacity, nullptr);
540 else
541 _setMPCast(pre_allocated_buffer);
542 }
543 m_md->nb_ref = _getNbRef();
544 m_md->size = 0;
546 }
547
548 void _directAllocate(Int64 new_capacity, RunQueue* queue)
549 {
550 if (!m_md->is_not_null)
551 _allocateMetaData();
552 _allocateMP(new_capacity, queue);
553 }
554
555 void _allocateMP(Int64 new_capacity, RunQueue* queue)
556 {
557 _setMPCast(m_md->_allocate(new_capacity, typeSize(), queue));
558 }
559
560 void _directReAllocate(Int64 new_capacity, RunQueue* queue)
561 {
562 _setMPCast(m_md->_reallocate(_currentMemoryInfo(), new_capacity, typeSize(), queue));
563 }
564
565 public:
566
567 void changeAllocator(const MemoryAllocationOptions& options, RunQueue* queue)
568 {
569 _setMPCast(m_md->_changeAllocator(options, _currentMemoryInfo(), typeSize(), queue));
571 }
572
573 void changeAllocator(const MemoryAllocationOptions& options)
574 {
575 _setMPCast(m_md->_changeAllocator(options, _currentMemoryInfo(), typeSize(), _nullRunQueue()));
577 }
578
579 protected:
580
582 virtual void _updateReferences()
583 {
584 }
585
587 {
588 return 1;
589 }
590
591 void _addRange(ConstReferenceType val, Int64 n)
592 {
593 Int64 s = m_md->size;
594 if ((s + n) > m_md->capacity)
595 _internalRealloc(s + n, true);
596 for (Int64 i = 0; i < n; ++i)
597 new (m_ptr + s + i) T(val);
598 m_md->size += n;
599 }
600
603 {
604 Int64 n = val.size();
605 const T* ptr = val.data();
606 Int64 s = m_md->size;
607 if ((s + n) > m_md->capacity)
608 _internalRealloc(s + n, true);
609 _createRange(s, s + n, ptr);
610 m_md->size += n;
611 }
612
615 {
616 if (m_md->nb_ref == 0) {
617 _destroy();
618 _internalDeallocate(_nullRunQueue());
619 }
620 }
621 void _destroy()
622 {
623 _destroyRange(0, m_md->size, IsPODType());
624 }
625 void _destroyRange(Int64, Int64, TrueType)
626 {
627 // Rien à faire pour un type POD.
628 }
629 void _destroyRange(Int64 abegin, Int64 aend, FalseType)
630 {
631 if (abegin < 0)
632 abegin = 0;
633 for (Int64 i = abegin; i < aend; ++i)
634 m_ptr[i].~T();
635 }
636 void _createRangeDefault(Int64, Int64, TrueType)
637 {
638 }
639 void _createRangeDefault(Int64 abegin, Int64 aend, FalseType)
640 {
641 if (abegin < 0)
642 abegin = 0;
643 for (Int64 i = abegin; i < aend; ++i)
644 new (m_ptr + i) T();
645 }
646 void _createRange(Int64 abegin, Int64 aend, ConstReferenceType value, TrueType)
647 {
648 if (abegin < 0)
649 abegin = 0;
650 for (Int64 i = abegin; i < aend; ++i)
651 m_ptr[i] = value;
652 }
653 void _createRange(Int64 abegin, Int64 aend, ConstReferenceType value, FalseType)
654 {
655 if (abegin < 0)
656 abegin = 0;
657 for (Int64 i = abegin; i < aend; ++i)
658 new (m_ptr + i) T(value);
659 }
660 void _createRange(Int64 abegin, Int64 aend, const T* values)
661 {
662 if (abegin < 0)
663 abegin = 0;
664 for (Int64 i = abegin; i < aend; ++i) {
665 new (m_ptr + i) T(*values);
666 ++values;
667 }
668 }
669 void _fill(ConstReferenceType value)
670 {
671 for (Int64 i = 0, n = size(); i < n; ++i)
672 m_ptr[i] = value;
673 }
674 void _clone(const ThatClassType& orig_array)
675 {
676 Int64 that_size = orig_array.size();
677 _internalAllocate(that_size, _nullRunQueue());
678 m_md->size = that_size;
679 m_md->dim1_size = orig_array.m_md->dim1_size;
680 m_md->dim2_size = orig_array.m_md->dim2_size;
681 _createRange(0, that_size, orig_array.m_ptr);
682 }
683 template <typename PodType>
684 void _resizeHelper(Int64 s, PodType pod_type, RunQueue* queue)
685 {
686 if (s < 0)
687 s = 0;
688 if (s > m_md->size) {
689 this->_internalRealloc(s, false, queue);
690 this->_createRangeDefault(m_md->size, s, pod_type);
691 }
692 else {
693 this->_destroyRange(s, m_md->size, pod_type);
694 if (m_meta_data.is_collective_allocator) {
695 this->_internalRealloc(s, false, queue);
696 }
697 }
698 m_md->size = s;
699 }
700 void _resize(Int64 s)
701 {
702 _resizeHelper(s, IsPODType(), _nullRunQueue());
703 }
705 void _resizeNoInit(Int64 s, RunQueue* queue = nullptr)
706 {
707 _resizeHelper(s, TrueType{}, queue);
708 }
709 void _clear()
710 {
711 this->_destroyRange(0, m_md->size, IsPODType());
712 m_md->size = 0;
713 }
715 void _resize(Int64 s, ConstReferenceType value)
716 {
717 if (s < 0)
718 s = 0;
719 if (s > m_md->size) {
720 this->_internalRealloc(s, false);
721 this->_createRange(m_md->size, s, value, IsPODType());
722 }
723 else {
724 this->_destroyRange(s, m_md->size, IsPODType());
725 if (m_meta_data.is_collective_allocator) {
726 this->_internalRealloc(s, false);
727 }
728 }
729 m_md->size = s;
730 }
731 void _copy(const T* rhs_begin, TrueType)
732 {
733 _copyFromMemory(rhs_begin);
734 }
735 void _copy(const T* rhs_begin, FalseType)
736 {
737 for (Int64 i = 0, n = m_md->size; i < n; ++i)
738 m_ptr[i] = rhs_begin[i];
739 }
740 void _copy(const T* rhs_begin)
741 {
742 _copy(rhs_begin, IsPODType());
743 }
744
754 {
755 const T* rhs_begin = rhs.data();
756 Int64 rhs_size = rhs.size();
757 const Int64 current_size = m_md->size;
758 T* abegin = m_ptr;
759 // Vérifie que \a rhs n'est pas un élément à l'intérieur de ce tableau
760 if (abegin >= rhs_begin && abegin < (rhs_begin + rhs_size))
761 ArrayMetaData::overlapError(abegin, m_md->size, rhs_begin, rhs_size);
762
763 if (rhs_size > current_size) {
764 this->_internalRealloc(rhs_size, false);
765 // Crée les nouveaux éléments
766 this->_createRange(m_md->size, rhs_size, rhs_begin + current_size);
767 // Copie les éléments déjà existant
768 _copy(rhs_begin);
769 m_md->size = rhs_size;
770 }
771 else {
772 this->_destroyRange(rhs_size, current_size, IsPODType{});
773 m_md->size = rhs_size;
774 _copy(rhs_begin);
775 }
776 }
777
785 void _move(ThatClassType& rhs) ARCCORE_NOEXCEPT
786 {
787 if (&rhs == this)
788 return;
789
790 // Comme il n'y a qu'une seule référence sur le tableau actuel, on peut
791 // directement libérer la mémoire.
792 _destroy();
793 _internalDeallocate(_nullRunQueue());
794
795 _setMP(rhs.m_ptr);
796
797 _copyMetaData(rhs);
798
799 // Indique que \a rhs est vide.
800 rhs._reset();
801 }
802
809 void _swap(ThatClassType& rhs) ARCCORE_NOEXCEPT
810 {
811 std::swap(m_ptr, rhs.m_ptr);
812 _swapMetaData(rhs);
813 }
814
815 void _shrink()
816 {
817 _shrink(size());
818 }
819
820 // Réalloue la mémoire pour avoir une capacité proche de \a new_capacity
821 void _shrink(Int64 new_capacity)
822 {
823 if (_isSharedNull())
824 return;
825 // On n'augmente pas la capacité avec cette méthode
826 if (new_capacity > this->capacity())
827 return;
828 if (new_capacity < 4)
829 new_capacity = 4;
830 _internalReallocate(new_capacity, _nullRunQueue());
831 }
832
838 void _reset()
839 {
840 _setToSharedNull();
841 }
842
843 constexpr Integer _clampSizeOffet(Int64 offset, Int32 asize) const
844 {
845 Int64 max_size = m_md->size - offset;
846 if (asize > max_size)
847 // On est certain de ne pas dépasser 32 bits car on est inférieur à asize.
848 asize = static_cast<Integer>(max_size);
849 return asize;
850 }
851
852 // Uniquement pour UniqueArray et UniqueArray2
853 void _assignFromArray(const AbstractArray<T>& rhs)
854 {
855 if (&rhs == this)
856 return;
857 Span<const T> rhs_span(rhs);
858 if (rhs.allocator() == this->allocator()) {
859 _resizeAndCopyView(rhs_span);
860 }
861 else {
862 _destroy();
863 _internalDeallocate(_nullRunQueue());
864 _reset();
865 _initFromAllocator(rhs.allocationOptions(), 0);
866 _initFromSpan(rhs_span);
867 }
868 }
869
870 protected:
871
872 void _setMP(TrueImpl* new_mp)
873 {
874 m_ptr = new_mp;
875 }
876
877 void _setMP2(TrueImpl* new_mp, ArrayMetaData* new_md)
878 {
879 _setMP(new_mp);
880 // Il ne faut garder le nouveau m_md que s'il est alloué
881 // sinon on risque d'avoir des références sur des objets temporaires
882 m_md = new_md;
883 if (!m_md->is_allocated_by_new)
884 m_md = &m_meta_data;
885 }
886
887 bool _isSharedNull()
888 {
889 return m_ptr == nullptr;
890 }
891
892 private:
893
894 void _setToSharedNull()
895 {
896 m_ptr = nullptr;
897 m_meta_data = ArrayMetaData();
898 m_md = &m_meta_data;
899 }
900 void _setMPCast(void* p)
901 {
902 _setMP(reinterpret_cast<TrueImpl*>(p));
903 }
904};
905
906/*---------------------------------------------------------------------------*/
907/*---------------------------------------------------------------------------*/
908
909} // namespace Arcane
910
911/*---------------------------------------------------------------------------*/
912/*---------------------------------------------------------------------------*/
913
914#endif
Types et fonctions associés aux classes SpanImpl, SmallSpan et 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.