Files CCore/inc/CompactList.h CCore/src/CompactList.cpp
Compact lists are variants of traditional lists. They have the same set of methods and behavior, except compact lists move elements during delete operations. Compact lists are more efficient and consume less memory, than traditional. They require the object type to be swappable. They also have no node allocator template parameter: compact node allocator is always used. Constructor arguments are forwarded to the allocator.
This is a variant of the LinearDList.
template <class T>
class CompactList : NoCopy
{
....
public:
// constructors
template <class ... SS>
explicit CompactList(SS && ... ss) noexcept;
~CompactList();
// std move
CompactList(CompactList &&obj) noexcept;
CompactList & operator = (CompactList &&obj) noexcept;
// props
ulen operator + () const;
bool operator ! () const;
ulen getCount() const;
// content
T * getTop();
const T * getTop() const;
const T * getTop_const() const;
template <class S>
struct Cur
{
....
// object ptr
void * operator + () const;
bool operator ! () const;
S * getPtr() const;
S & operator * () const;
S * operator -> () const;
// cursor
void operator ++ ();
void operator -- ();
};
Cur<T> getStart();
Cur<const T> getStart() const;
Cur<const T> getStart_const() const;
template <class S>
struct CountCur
{
....
};
CountCur<T> begin();
CountCur<T> end();
CountCur<const T> begin() const;
CountCur<const T> end() const;
// ins/del
template <class ... SS>
T * ins(SS && ... ss);
template <class S,class ... SS>
T * insBefore(Cur<S> pos,SS && ... ss); // +pos
template <class S,class ... SS>
T * insAfter(Cur<S> pos,SS && ... ss); // +pos
bool del();
template <class S>
void delAndMove(Cur<S> &pos); // +pos
ulen erase();
// apply
template <class FuncInit>
void apply(FuncInit func_init);
template <class FuncInit>
void apply(FuncInit func_init) const;
template <class FuncInit>
void apply_const(FuncInit func_init) const;
// swap/move objects
void objSwap(CompactList<T> &obj);
explicit CompactList(ToMoveCtor<CompactList<T> > obj);
};
This is a variant of the LinearDList2.
template <class T>
class CompactList2 : NoCopy
{
....
public:
// constructors
template <class ... SS>
explicit CompactList2(SS && ... ss) noexcept;
~CompactList2();
// std move
CompactList2(CompactList2 &&obj) noexcept;
CompactList2 & operator = (CompactList2 &&obj) noexcept;
// props
ulen operator + () const;
bool operator ! () const;
ulen getCount() const;
// content
T * getFirst();
const T * getFirst() const;
const T * getFirst_const() const;
T * getLast();
const T * getLast() const;
const T * getLast_const() const;
template <class S>
struct Cur
{
....
// object ptr
void * operator + () const;
bool operator ! () const;
S * getPtr() const;
S & operator * () const;
S * operator -> () const;
// cursor
void operator ++ ();
void operator -- ();
};
Cur<T> getStart();
Cur<const T> getStart() const;
Cur<const T> getStart_const() const;
template <class S>
struct RevCur
{
....
// object ptr
void * operator + () const;
bool operator ! () const;
S * getPtr() const;
S & operator * () const;
S * operator -> () const;
// cursor
void operator ++ ();
void operator -- ();
};
RevCur<T> getStartReverse();
RevCur<const T> getStartReverse() const;
RevCur<const T> getStartReverse_const() const;
template <class S>
struct CountCur
{
....
};
CountCur<T> begin();
CountCur<T> end();
CountCur<const T> begin() const;
CountCur<const T> end() const;
template <class S>
struct RevCountCur
{
....
};
RevCountCur<T> rbegin();
RevCountCur<T> rend();
RevCountCur<const T> rbegin() const;
RevCountCur<const T> rend() const;
template <class S>
struct ReverseAdapter
{
RevCountCur<S> cur;
ReverseAdapter(RevCountCur<S> cur_) : cur(cur_) {}
RevCountCur<S> begin() const { return cur; }
RevCountCur<S> end() const { return RevCountCur<S>(); }
};
ReverseAdapter<T> reverse();
ReverseAdapter<const T> reverse() const;
ReverseAdapter<const T> reverse_const() const;
// ins/del
template <class ... SS>
T * insFirst(SS && ... ss);
template <class ... SS>
T * insLast(SS && ... ss);
template <class S,class ... SS>
T * insBefore(Cur<S> pos,SS && ... ss); // +pos
template <class S,class ... SS>
T * insBefore(RevCur<S> pos,SS && ... ss); // +pos
template <class S,class ... SS>
T * insAfter(Cur<S> pos,SS && ... ss); // +pos
template <class S,class ... SS>
T * insAfter(RevCur<S> pos,SS && ... ss); // +pos
bool delFirst();
bool delLast();
template <class S>
void delAndMove(Cur<S> &pos); // +pos
template <class S>
void delAndMove(RevCur<S> &pos); // +pos
ulen erase();
// apply
template <class FuncInit>
void apply(FuncInit func_init);
template <class FuncInit>
void apply(FuncInit func_init) const;
template <class FuncInit>
void apply_const(FuncInit func_init) const;
template <class FuncInit>
void applyReverse(FuncInit func_init);
template <class FuncInit>
void applyReverse(FuncInit func_init) const;
template <class FuncInit>
void applyReverse_const(FuncInit func_init) const;
// swap/move objects
void objSwap(CompactList2<T> &obj);
explicit CompactList2(ToMoveCtor<CompactList2<T> > obj);
};
This is a variant of the CircularDList.
template <class T>
class CompactCircularList : NoCopy
{
....
public:
// constructors
template <class ... SS>
explicit CompactCircularList(SS && ... ss) noexcept;
~CompactCircularList();
// std move
CompactCircularList(CompactCircularList &&obj) noexcept;
CompactCircularList & operator = (CompactCircularList &&obj) noexcept;
// props
ulen operator + () const;
bool operator ! () const;
ulen getCount() const;
// content
T * getTop();
const T * getTop() const;
const T * getTop_const() const;
template <class S>
struct Cur
{
....
// object ptr
void * operator + () const;
bool operator ! () const;
S * getPtr() const;
S & operator * () const;
S * operator -> () const;
// cursor
void operator ++ ();
void operator -- ();
};
Cur<T> getStart();
Cur<const T> getStart() const;
Cur<const T> getStart_const() const;
template <class S>
struct RevCur
{
....
// object ptr
void * operator + () const;
bool operator ! () const;
S * getPtr() const;
S & operator * () const;
S * operator -> () const;
// cursor
void operator ++ ();
void operator -- ();
};
RevCur<T> getStartReverse();
RevCur<const T> getStartReverse() const;
RevCur<const T> getStartReverse_const() const;
template <class S>
struct CountCur
{
....
};
CountCur<T> begin();
CountCur<T> end();
CountCur<const T> begin() const;
CountCur<const T> end() const;
template <class S>
struct RevCountCur
{
....
};
RevCountCur<T> rbegin();
RevCountCur<T> rend();
RevCountCur<const T> rbegin() const;
RevCountCur<const T> rend() const;
template <class S>
struct ReverseAdapter
{
RevCountCur<S> cur;
ReverseAdapter(RevCountCur<S> cur_) : cur(cur_) {}
RevCountCur<S> begin() const { return cur; }
RevCountCur<S> end() const { return RevCountCur<S>(); }
};
ReverseAdapter<T> reverse();
ReverseAdapter<const T> reverse() const;
ReverseAdapter<const T> reverse_const() const;
// ins/del
template <class ... SS>
T * insFirst(SS && ... ss);
template <class ... SS>
T * insLast(SS && ... ss);
template <class S,class ... SS>
T * insBefore(Cur<S> pos,SS && ... ss); // +pos
template <class S,class ... SS>
T * insBefore(RevCur<S> &pos,SS && ... ss); // +pos
template <class S,class ... SS>
T * insAfter(Cur<S> &pos,SS && ... ss); // +pos
template <class S,class ... SS>
T * insAfter(RevCur<S> pos,SS && ... ss); // +pos
bool delFirst();
bool delLast();
template <class S>
void delAndMove(Cur<S> &pos); // +pos
template <class S>
void delAndMove(RevCur<S> &pos); // +pos
ulen erase();
T * rotateForward(); // return top element moved to bottom
T * rotateBackward(); // return bottom element moved to top
// apply
template <class FuncInit>
void apply(FuncInit func_init);
template <class FuncInit>
void apply(FuncInit func_init) const;
template <class FuncInit>
void apply_const(FuncInit func_init) const;
template <class FuncInit>
void applyReverse(FuncInit func_init);
template <class FuncInit>
void applyReverse(FuncInit func_init) const;
template <class FuncInit>
void applyReverse_const(FuncInit func_init) const;
// swap/move objects
void objSwap(CompactCircularList<T> &obj);
explicit CompactCircularList(ToMoveCtor<CompactCircularList<T> > obj);
};