Arcane  v4.1.0.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-2025 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-2025 */
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->_setHostDeviceMemoryLocation(location);
357 }
358
361 {
362 return m_md->allocation_options.hostDeviceMemoryLocation();
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 return;
421 _internalRealloc(new_capacity, false);
422 }
423
428 template <typename PodType>
429 void _internalRealloc(Int64 new_capacity, bool compute_capacity, PodType pod_type, RunQueue* queue = nullptr)
430 {
431 if (_isSharedNull()) {
432 if (new_capacity != 0)
433 _internalAllocate(new_capacity, queue);
434 return;
435 }
436
437 Int64 acapacity = new_capacity;
438 if (compute_capacity) {
439 acapacity = m_md->capacity;
440 //std::cout << " REALLOC: want=" << wanted_size << " current_capacity=" << capacity << '\n';
441 while (new_capacity > acapacity)
442 acapacity = (acapacity == 0) ? 4 : (acapacity + 1 + acapacity / 2);
443 //std::cout << " REALLOC: want=" << wanted_size << " new_capacity=" << capacity << '\n';
444 }
445 // Si la nouvelle capacité est inférieure à la courante,ne fait rien.
446 if (acapacity <= m_md->capacity)
447 return;
448 _internalReallocate(acapacity, pod_type, queue);
449 }
450
451 void _internalRealloc(Int64 new_capacity, bool compute_capacity)
452 {
453 _internalRealloc(new_capacity, compute_capacity, IsPODType());
454 }
455
457 void _internalReallocate(Int64 new_capacity, TrueType, RunQueue* queue)
458 {
459 T* old_ptr = m_ptr;
460 Int64 old_capacity = m_md->capacity;
461 _directReAllocate(new_capacity, queue);
462 bool update = (new_capacity < old_capacity) || (m_ptr != old_ptr);
463 if (update) {
465 }
466 }
467
469 void _internalReallocate(Int64 new_capacity, FalseType, RunQueue* queue)
470 {
471 T* old_ptr = m_ptr;
472 ArrayMetaData* old_md = m_md;
473 AllocatedMemoryInfo old_mem_info = _currentMemoryInfo();
474 Int64 old_size = m_md->size;
475 _directAllocate(new_capacity, queue);
476 if (m_ptr != old_ptr) {
477 for (Int64 i = 0; i < old_size; ++i) {
478 new (m_ptr + i) T(old_ptr[i]);
479 old_ptr[i].~T();
480 }
481 m_md->nb_ref = old_md->nb_ref;
482 m_md->_deallocate(old_mem_info, queue);
484 }
485 }
486 // Libère la mémoire
487 void _internalDeallocate(RunQueue* queue = nullptr)
488 {
489 if (!_isSharedNull())
490 m_md->_deallocate(_currentMemoryInfo(), queue);
491 if (m_md->is_not_null)
492 _deallocateMetaData(m_md);
493 }
494 void _internalAllocate(Int64 new_capacity, RunQueue* queue)
495 {
496 _directAllocate(new_capacity, queue);
497 m_md->nb_ref = _getNbRef();
499 }
500
501 void _copyFromMemory(const T* source)
502 {
503 m_md->_copyFromMemory(m_ptr, source, sizeof(T), _nullRunQueue());
504 }
505
506 private:
507
517 void* pre_allocated_buffer = nullptr)
518 {
519 IMemoryAllocator* wanted_allocator = options.allocator();
520 if (!wanted_allocator) {
521 wanted_allocator = ArrayMetaData::_defaultAllocator();
522 options.setAllocator(wanted_allocator);
523 }
524 _allocateMetaData();
525 m_md->allocation_options = options;
526 if (new_capacity > 0) {
527 if (!pre_allocated_buffer)
528 _allocateMP(new_capacity, options.runQueue());
529 else
530 _setMPCast(pre_allocated_buffer);
531 }
532 m_md->nb_ref = _getNbRef();
533 m_md->size = 0;
535 }
536
537 void _directAllocate(Int64 new_capacity, RunQueue* queue)
538 {
539 if (!m_md->is_not_null)
540 _allocateMetaData();
541 _allocateMP(new_capacity, queue);
542 }
543
544 void _allocateMP(Int64 new_capacity, RunQueue* queue)
545 {
546 _setMPCast(m_md->_allocate(new_capacity, typeSize(), queue));
547 }
548
549 void _directReAllocate(Int64 new_capacity, RunQueue* queue)
550 {
551 _setMPCast(m_md->_reallocate(_currentMemoryInfo(), new_capacity, typeSize(), queue));
552 }
553
554 public:
555
556 void printInfos(std::ostream& o)
557 {
558 o << " Infos: size=" << m_md->size << " capacity=" << m_md->capacity << '\n';
559 }
560
561 protected:
562
564 virtual void _updateReferences()
565 {
566 }
567
569 {
570 return 1;
571 }
572
573 void _addRange(ConstReferenceType val, Int64 n)
574 {
575 Int64 s = m_md->size;
576 if ((s + n) > m_md->capacity)
577 _internalRealloc(s + n, true);
578 for (Int64 i = 0; i < n; ++i)
579 new (m_ptr + s + i) T(val);
580 m_md->size += n;
581 }
582
585 {
586 Int64 n = val.size();
587 const T* ptr = val.data();
588 Int64 s = m_md->size;
589 if ((s + n) > m_md->capacity)
590 _internalRealloc(s + n, true);
591 _createRange(s, s + n, ptr);
592 m_md->size += n;
593 }
594
597 {
598 if (m_md->nb_ref == 0) {
599 _destroy();
600 _internalDeallocate(_nullRunQueue());
601 }
602 }
603 void _destroy()
604 {
605 _destroyRange(0, m_md->size, IsPODType());
606 }
607 void _destroyRange(Int64, Int64, TrueType)
608 {
609 // Rien à faire pour un type POD.
610 }
611 void _destroyRange(Int64 abegin, Int64 aend, FalseType)
612 {
613 if (abegin < 0)
614 abegin = 0;
615 for (Int64 i = abegin; i < aend; ++i)
616 m_ptr[i].~T();
617 }
618 void _createRangeDefault(Int64, Int64, TrueType)
619 {
620 }
621 void _createRangeDefault(Int64 abegin, Int64 aend, FalseType)
622 {
623 if (abegin < 0)
624 abegin = 0;
625 for (Int64 i = abegin; i < aend; ++i)
626 new (m_ptr + i) T();
627 }
628 void _createRange(Int64 abegin, Int64 aend, ConstReferenceType value, TrueType)
629 {
630 if (abegin < 0)
631 abegin = 0;
632 for (Int64 i = abegin; i < aend; ++i)
633 m_ptr[i] = value;
634 }
635 void _createRange(Int64 abegin, Int64 aend, ConstReferenceType value, FalseType)
636 {
637 if (abegin < 0)
638 abegin = 0;
639 for (Int64 i = abegin; i < aend; ++i)
640 new (m_ptr + i) T(value);
641 }
642 void _createRange(Int64 abegin, Int64 aend, const T* values)
643 {
644 if (abegin < 0)
645 abegin = 0;
646 for (Int64 i = abegin; i < aend; ++i) {
647 new (m_ptr + i) T(*values);
648 ++values;
649 }
650 }
651 void _fill(ConstReferenceType value)
652 {
653 for (Int64 i = 0, n = size(); i < n; ++i)
654 m_ptr[i] = value;
655 }
656 void _clone(const ThatClassType& orig_array)
657 {
658 Int64 that_size = orig_array.size();
659 _internalAllocate(that_size, _nullRunQueue());
660 m_md->size = that_size;
661 m_md->dim1_size = orig_array.m_md->dim1_size;
662 m_md->dim2_size = orig_array.m_md->dim2_size;
663 _createRange(0, that_size, orig_array.m_ptr);
664 }
665 template <typename PodType>
666 void _resizeHelper(Int64 s, PodType pod_type, RunQueue* queue)
667 {
668 if (s < 0)
669 s = 0;
670 if (s > m_md->size) {
671 this->_internalRealloc(s, false, pod_type, queue);
672 this->_createRangeDefault(m_md->size, s, pod_type);
673 }
674 else {
675 this->_destroyRange(s, m_md->size, pod_type);
676 }
677 m_md->size = s;
678 }
679 void _resize(Int64 s)
680 {
681 _resizeHelper(s, IsPODType(), _nullRunQueue());
682 }
684 void _resizeNoInit(Int64 s, RunQueue* queue = nullptr)
685 {
686 _resizeHelper(s, TrueType{}, queue);
687 }
688 void _clear()
689 {
690 this->_destroyRange(0, m_md->size, IsPODType());
691 m_md->size = 0;
692 }
694 void _resize(Int64 s, ConstReferenceType value)
695 {
696 if (s < 0)
697 s = 0;
698 if (s > m_md->size) {
699 this->_internalRealloc(s, false);
700 this->_createRange(m_md->size, s, value, IsPODType());
701 }
702 else {
703 this->_destroyRange(s, m_md->size, IsPODType());
704 }
705 m_md->size = s;
706 }
707 void _copy(const T* rhs_begin, TrueType)
708 {
709 _copyFromMemory(rhs_begin);
710 }
711 void _copy(const T* rhs_begin, FalseType)
712 {
713 for (Int64 i = 0, n = m_md->size; i < n; ++i)
714 m_ptr[i] = rhs_begin[i];
715 }
716 void _copy(const T* rhs_begin)
717 {
718 _copy(rhs_begin, IsPODType());
719 }
720
730 {
731 const T* rhs_begin = rhs.data();
732 Int64 rhs_size = rhs.size();
733 const Int64 current_size = m_md->size;
734 T* abegin = m_ptr;
735 // Vérifie que \a rhs n'est pas un élément à l'intérieur de ce tableau
736 if (abegin >= rhs_begin && abegin < (rhs_begin + rhs_size))
737 ArrayMetaData::overlapError(abegin, m_md->size, rhs_begin, rhs_size);
738
739 if (rhs_size > current_size) {
740 this->_internalRealloc(rhs_size, false);
741 // Crée les nouveaux éléments
742 this->_createRange(m_md->size, rhs_size, rhs_begin + current_size);
743 // Copie les éléments déjà existant
744 _copy(rhs_begin);
745 m_md->size = rhs_size;
746 }
747 else {
748 this->_destroyRange(rhs_size, current_size, IsPODType{});
749 m_md->size = rhs_size;
750 _copy(rhs_begin);
751 }
752 }
753
761 void _move(ThatClassType& rhs) ARCCORE_NOEXCEPT
762 {
763 if (&rhs == this)
764 return;
765
766 // Comme il n'y a qu'une seule référence sur le tableau actuel, on peut
767 // directement libérer la mémoire.
768 _destroy();
769 _internalDeallocate(_nullRunQueue());
770
771 _setMP(rhs.m_ptr);
772
773 _copyMetaData(rhs);
774
775 // Indique que \a rhs est vide.
776 rhs._reset();
777 }
778
785 void _swap(ThatClassType& rhs) ARCCORE_NOEXCEPT
786 {
787 std::swap(m_ptr, rhs.m_ptr);
788 _swapMetaData(rhs);
789 }
790
791 void _shrink()
792 {
793 _shrink(size());
794 }
795
796 // Réalloue la mémoire pour avoir une capacité proche de \a new_capacity
797 void _shrink(Int64 new_capacity)
798 {
799 if (_isSharedNull())
800 return;
801 // On n'augmente pas la capacité avec cette méthode
802 if (new_capacity > this->capacity())
803 return;
804 if (new_capacity < 4)
805 new_capacity = 4;
806 _internalReallocate(new_capacity, IsPODType(), _nullRunQueue());
807 }
808
814 void _reset()
815 {
816 _setToSharedNull();
817 }
818
819 constexpr Integer _clampSizeOffet(Int64 offset, Int32 asize) const
820 {
821 Int64 max_size = m_md->size - offset;
822 if (asize > max_size)
823 // On est certain de ne pas dépasser 32 bits car on est inférieur à asize.
824 asize = static_cast<Integer>(max_size);
825 return asize;
826 }
827
828 // Uniquement pour UniqueArray et UniqueArray2
829 void _assignFromArray(const AbstractArray<T>& rhs)
830 {
831 if (&rhs == this)
832 return;
833 Span<const T> rhs_span(rhs);
834 if (rhs.allocator() == this->allocator()) {
835 _resizeAndCopyView(rhs_span);
836 }
837 else {
838 _destroy();
839 _internalDeallocate(_nullRunQueue());
840 _reset();
841 _initFromAllocator(rhs.allocationOptions(), 0);
842 _initFromSpan(rhs_span);
843 }
844 }
845
846 protected:
847
848 void _setMP(TrueImpl* new_mp)
849 {
850 m_ptr = new_mp;
851 }
852
853 void _setMP2(TrueImpl* new_mp, ArrayMetaData* new_md)
854 {
855 _setMP(new_mp);
856 // Il ne faut garder le nouveau m_md que s'il est alloué
857 // sinon on risque d'avoir des références sur des objets temporaires
858 m_md = new_md;
859 if (!m_md->is_allocated_by_new)
860 m_md = &m_meta_data;
861 }
862
863 bool _isSharedNull()
864 {
865 return m_ptr == nullptr;
866 }
867
868 private:
869
870 void _setToSharedNull()
871 {
872 m_ptr = nullptr;
873 m_meta_data = ArrayMetaData();
874 m_md = &m_meta_data;
875 }
876 void _setMPCast(void* p)
877 {
878 _setMP(reinterpret_cast<TrueImpl*>(p));
879 }
880};
881
882/*---------------------------------------------------------------------------*/
883/*---------------------------------------------------------------------------*/
884
885} // namespace Arcane
886
887/*---------------------------------------------------------------------------*/
888/*---------------------------------------------------------------------------*/
889
890#endif
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.
void _internalReallocate(Int64 new_capacity, FalseType, RunQueue *queue)
Réallocation pour un type complexe (non POD)
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 _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 _internalRealloc(Int64 new_capacity, bool compute_capacity, PodType pod_type, RunQueue *queue=nullptr)
Réalloue le tableau pour une nouvelle capacité égale à new_capacity.
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.
void _internalReallocate(Int64 new_capacity, TrueType, RunQueue *queue)
Réallocation pour un type POD.
Integer length() const
Nombre d'éléments du vecteur.
File d'exécution pour un accélérateur.
Informations sur une zone mémoire allouée.
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)
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.
Structure équivalente à la valeur booléenne vrai.