12#ifndef ARCANE_UTILS_LIST_H
13#define ARCANE_UTILS_LIST_H
17#include "arcane/utils/ListImpl.h"
18#include "arcane/utils/Enumerator.h"
19#include "arcane/utils/Ptr.h"
20#include "arcane/utils/Collection.h"
21#include "arcane/utils/Iostream.h"
38 typedef void* VoidPtr;
46 , m_elem_size(elem_size)
51 void reset() { m_current = m_begin; }
54 m_current = (
char*)m_current + m_elem_size;
55 return m_current < m_end;
57 VoidPtr current() {
return m_current; }
59 bool operator++() {
return moveNext(); }
79 typedef const void* VoidPtr;
87 , m_elem_size(elem_size)
92 void reset() { m_current = m_begin; }
95 m_current = (
const char*)m_current + m_elem_size;
96 return m_current < m_end;
98 VoidPtr current() {
return m_current; }
100 bool operator++() {
return moveNext(); }
101 VoidPtr
operator*() {
return current(); }
114template <
typename T>
class List;
139 inline bool moveNext()
141 Ptr v =
reinterpret_cast<Ptr
>(m_current);
144 return m_current < m_end;
148 return reinterpret_cast<Ptr
>(m_current);
150 inline bool operator++()
154 inline Ref operator*()
158 inline Ptr operator->()
175 typedef const T* Ptr;
176 typedef const T& Ref;
187 inline bool moveNext()
189 Ptr v =
reinterpret_cast<Ptr
>(m_current);
192 return m_current < m_end;
196 return reinterpret_cast<Ptr
>(m_current);
198 inline bool operator++()
202 inline Ref operator*()
206 inline Ptr operator->()
225 typedef Collection<T> BaseClass;
229 typedef ListImplT<T> Impl;
234 typedef typename Vec::value_type value_type;
235 typedef typename Vec::iterator iterator;
236 typedef typename Vec::const_iterator const_iterator;
237 typedef typename Vec::pointer pointer;
238 typedef typename Vec::const_pointer const_pointer;
239 typedef typename Vec::reference reference;
240 typedef typename Vec::const_reference const_reference;
245 typedef ConstIterT<List<T>> const_iter;
250 : BaseClass(new Impl())
253 : BaseClass(new Impl(from))
255 List(
const ArrayView<T>& from)
256 : BaseClass(new Impl(from))
258 explicit List(
const EnumeratorT<T>& from)
259 : BaseClass(new Impl(from))
264 void resize(Integer new_size)
266 _cast().resize(new_size);
269 T& operator[](Integer i)
274 const T& operator[](Integer i)
const
280 void clone(
const Collection<T>& base)
284 _cast().assign(base);
290 return List<T>(
new Impl(*
this));
295 const_iterator begin()
const {
return _cast().begin(); }
296 const_iterator end()
const {
return _cast().end(); }
298 T* begin2()
const {
return _cast().begin2(); }
299 T* end2()
const {
return _cast().end2(); }
302 template <
typename Function> Function
305 return _cast().each(f);
308 template <
typename Function> iterator
311 iterator _end = end2();
312 iterator i = std::find_if(begin2(), _end, f);
318 template <
typename Function> const_iterator
319 find_if(Function f)
const
321 const_iterator _end = end();
322 const_iterator i = std::find_if(begin(), _end, f);
336 Impl& _cast() {
return *
static_cast<Impl*
>(this->_noNullRef()); }
337 const Impl& _cast()
const {
return *
static_cast<const Impl*
>(this->_noNullRef()); }
343template <
typename T>
inline ListEnumeratorT<T>::
344ListEnumeratorT(
const List<T>& collection)
345: ListEnumeratorBase(collection.begin2() - 1, collection.end2(), sizeof(T))
352template <
typename T>
inline ListConstEnumeratorT<T>::
353ListConstEnumeratorT(
const List<T>& collection)
354: ListConstEnumeratorBase(collection.begin2() - 1, collection.end2(), sizeof(T))
Classe de base d'une collection fortement typée.
Enumérateur générique constant pour un tableau.
Enumérateur générique pour un tableau.
Enumérateur typé pour un tableau.
Implémentation d'une collection d'éléments sous forme de vecteur.
void clone(const Collection< T > &base)
Clone la collection base.
Function each(Function f)
Applique le fonctor f à tous les éléments du tableau.
ListEnumeratorT< T > Enumerator
Type d'un itérateur constant sur tout le tableau.
List< T > clone() const
Clone la collection.
Vue constante d'un tableau de type T.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Real2 operator*(Real sca, const Real2Proxy &vec)
Multiplication par un scalaire.