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;
55 virtual size_t size()
const {
return std::vector<T>::size(); }
59 {
return index >= 0 && index <
size(); }
60 virtual Object
getArrayItem(
int index )
const {
return Object::value(std::vector<T>::at( index )); }
61 virtual void setArrayItem(
int index, Object o ) { std::vector<T>::at( index ) = o->GenericObject::value<T>(); }
65 virtual void reserveArray(
size_t s ) { std::vector<T>::reserve(s); }
69 virtual void resizeArray(
size_t s ) { std::vector<T>::resize(s); }
72 virtual void removeArrayItem(
int i ) { std::vector<T>::erase( std::vector<T>::begin() + i ); }
75 virtual void insertArrayItem(
int i, Object o ) { std::vector<T>::insert( std::vector<T>::begin() + i, o->GenericObject::value<T>() ); }
88 const ArrayIterator &end ) :
89 _iterator( begin ), _end( end )
97 return _iterator != _end;
103 return Object::value(*_iterator);
118 ArrayIterator _iterator;
interfaced_iterator(const ArrayIterator &begin, const ArrayIterator &end)
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 void next()
Point to the next element of the iterable container.
virtual Object currentValue() const
Access the value of the element pointed to by the iterator.
virtual Object objectIterator() const
returns an object implementing the IteratorIntrerface
virtual bool hasItem(int index) const
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 size_t size() const
virtual void setArrayItem(int index, Object o)
interfaced_iterator getIterator() const
virtual void insertArrayItem(int i, Object o)
inserts an element into the array.
virtual Object getArrayItem(int index) const
virtual bool isContiguous() const
virtual void removeArrayItem(int i)
removes an element from the array.