11 #ifndef BIOPROCESSING_OBJECT_ARRAY_H 12 #define BIOPROCESSING_OBJECT_ARRAY_H 16 #include <cartobase/object/object.h> 22 class Array:
public virtual Interface,
23 public DynArrayInterface,
27 typedef typename std::vector<T>::const_iterator ArrayIterator;
42 class interfaced_iterator;
46 return interfaced_iterator( std::vector<T>::begin(), std::vector<T>::end() );
55 virtual size_t size()
const {
return std::vector<T>::size(); }
57 virtual Object
getArrayItem(
int index )
const {
return Object::value(std::vector<T>::at( index )); }
58 virtual void setArrayItem(
int index, Object o ) { std::vector<T>::at( index ) = o->GenericObject::value<T>(); }
62 virtual void reserveArray(
size_t s ) { std::vector<T>::reserve(s); }
66 virtual void resizeArray(
size_t s ) { std::vector<T>::resize(s); }
69 virtual void removeArrayItem(
int i ) { std::vector<T>::erase( std::vector<T>::begin() + i ); }
72 virtual void insertArrayItem(
int i, Object o ) { std::vector<T>::insert( std::vector<T>::begin() + i, o->GenericObject::value<T>() ); }
85 const ArrayIterator &end ) :
86 _iterator( begin ), _end( end )
94 return _iterator != _end;
100 return Object::value(*_iterator);
115 ArrayIterator _iterator;
virtual size_t size() const
virtual Object currentValue() const
Access the value of the element pointed to by the iterator.
virtual void next()
Point to the next element of the iterable container.
virtual void resizeArray(size_t s)
resize the array.
virtual void reserveArray(size_t s)
like the STL std::vector::reserve(), memory is reserved but no element is stored
virtual bool isValid() const
true if the iterator points to a valid value, false when the end of the iterable container has been r...
virtual Object objectIterator() const
returns an object implementing the IteratorIntrerface
virtual void insertArrayItem(int i, Object o)
inserts an element into the array.
interfaced_iterator(const ArrayIterator &begin, const ArrayIterator &end)
virtual void removeArrayItem(int i)
removes an element from the array.
virtual Object getArrayItem(int index) const
virtual void setArrayItem(int index, Object o)
interfaced_iterator getIterator() const