25 #ifndef ODLINKEDARRAY_H_INCLUDED
26 #define ODLINKEDARRAY_H_INCLUDED
30 template <
class T,
class A = OdObjectsAllocator<T> >
57 A::destroy(items(),
_size);
66 return *(items(
index));
71 return *(items(
index));
85 A::move(items(i+1), items(i), moved);
86 A::construct(items(i),
value);
102 A::destroy(items(0),
_size - newSize);
111 A::copy(items(
_size), src->items(), start);
115 A::move(src->items(), src->items(start), src->
_size);
119 A::destroy(items(i), 1);
122 A::move(items(i), items(i+1),
_size - i);
126 A::destroy(items(
_size--), 1);
182 _first->
_prev = page;
183 page->_next = _first;
196 prev->_next->_prev = page;
197 page->_next = prev->_next;
225 , _pageSize(pageSize)
239 PAGE *next, *curr = _first;
254 PAGE *curr = _last->_next;
272 T
data = _last->at(_last->_size - 1);
278 PAGE* p = _last->_prev;
307 operator const T*()
const {
359 return (!(*
this == it));
421 return this->_page->at(this->_ind);
425 return &(this->_page->at(this->_ind));
481 return iterator(_last, (_last ? _last->_size : 0));
494 while (it != endIt && *it != val)
504 while (it != endIt && *it != val)
524 int d = newSize -
size();
530 if(_last->_size < _pageSize) {
531 d0 =
odmin(d, (
int)(_pageSize - _last->_size));
532 _last->resize(_last->_size + d0);
536 while (d && _last->_next) {
537 _last = _last->_next;
539 d0 =
odmin(d, (
int)_pageSize);
545 while (d>=(
int)_pageSize)
547 addPage()->
resize(_pageSize);
562 PAGE* pToRemove = _last;
563 _last = _last->_prev;
590 PAGE* curPage = before._page;
593 if (curPage->
_size < _pageSize)
600 if (!prevPage || (prevPage->
_size + curInd) >= _pageSize)
602 prevPage = insertPage(prevPage);
606 prevPage->
moveFrom(curPage, curInd);
621 PAGE* curPage = at._page;
622 if (curPage == _last && curInd == (_last->_size - 1))
624 T
data = curPage->
at(curInd);
625 if (curPage->
_size == 1)
630 this->_first = curPage->
_next;
646 if (_last && _last->_size < _pageSize)
648 _last->append(
value);
692 itemNums += page->
_size;
ALLOCDLL_EXPORT void * odrxAlloc(size_t nBytes)
ALLOCDLL_EXPORT void odrxFree(void *pMemBlock)
void resize(size_type newSize)
void resize(size_type newSize, const T &value)
size_type insertAt(size_type i, const T &value)
void moveFrom(PAGE *src, size_type start)
static PAGE * allocate(size_type pageSize)
size_type append(const T &value)
const T & at(size_type index) const
bool operator==(const const_iterator &it) const
const_iterator operator-=(int n)
bool operator!=(const const_iterator &it) const
const T * operator->() const
OD_TYPENAME2 OD_LINKEDARRAY_SCOPE PAGE * _page
const_iterator(OD_TYPENAME2 OD_LINKEDARRAY_SCOPE PAGE *page, unsigned ind=0)
const_iterator operator++(int)
const_iterator & operator++()
const_iterator operator--(int)
const_iterator operator+=(int n)
const T & operator*() const
const_iterator & operator--()
iterator operator-=(int n)
iterator(OD_TYPENAME2 OD_LINKEDARRAY_SCOPE PAGE *page, unsigned ind=0)
iterator operator+=(int n)
iterator find(const T &val)
void append(const T &value)
const_iterator find(const T &val) const
iterator insert(iterator before, const T &val=T())
bool contains(const T &val) const
void resize(size_type newSize)
const_iterator begin() const
const_iterator end() const
OdLinkedArray(OdUInt32 pageSize=0x10)
GLint GLenum GLsizei GLsizei GLint GLsizei const void * data
GLsizei const GLfloat * value