21 #ifndef ELM_SORTEDLIST_H_
22 #define ELM_SORTEDLIST_H_
24 #include <elm/genstruct/SLList.h>
25 #include <elm/compare.h>
26 #include <elm/adapter.h>
31 template <
class T,
class C = Comparator<T>,
class A = IdAdapter<T> >
35 typedef typename A::key_t
key_t;
36 typedef typename A::val_t
val_t;
49 for (Iterator current(*
this); current; current++) {
50 int cmp = _c.doCompare(item, A::key(*current));
51 if(cmp > 0)
continue;
else if(!cmp)
return true;
else break;
57 inline operator bool(
void)
const {
return !list.
isEmpty(); }
65 inline Iterator(
const typename list_t::Iterator& iter)
73 for(Iterator current(*
this); current; current++)
74 if(_c.doCompare(A::key(value), A::key(*current)) < 0) {
81 template <
template <
class _>
class CC>
inline void addAll (
const CC<T> &items)
82 {
for(
typename CC<T>::Iterator item(items); item; item++)
add(item); }
83 inline void remove(
const T &item) { list.
remove(item); }
84 template <
template <
class _>
class CC>
inline void removeAll(
const CC<T> &items)
86 void remove(
const Iterator &iter) { list.
remove(iter); }
89 inline const T&
first(
void)
const {
return list.
first(); }
90 inline const T&
last(
void)
const {
return list.
last(); }
91 inline Iterator
find(
const T& item)
const
92 {
return Iterator(list.
find(item)); }
93 inline Iterator
find(
const T& item,
const Iterator& iter)
const
94 {
return list.
find(item, iter); }
SortedList(const C &c)
Definition: SortedList.h:39
void removeAll(const C &items)
Definition: SLList.h:106
void clear(void)
Definition: SortedList.h:70
Iterator find(const T &item) const
Definition: SortedList.h:91
bool contains(const key_t &item) const
Definition: SortedList.h:48
Iterator(void)
Definition: SortedList.h:61
bool isEmpty(void) const
Definition: SortedList.h:56
void add(const T &value)
Definition: SortedList.h:72
void remove(const T &value)
Definition: SLList.h:109
void removeFirst(void)
Definition: SLList.h:135
void addAll(const CC< T > &items)
Definition: SortedList.h:81
const T & last(void) const
Definition: SortedList.h:90
T & last(void)
Definition: SLList.h:121
Iterator find(const T &item, const Iterator &iter) const
Definition: SortedList.h:93
value_t value(CString name, int value)
Definition: rtti.h:40
SortedList(SortedList &source)
Definition: SortedList.h:40
void removeLast(void)
Definition: SLList.h:136
int count(void) const
Definition: SLList.h:60
void addBefore(const Iterator &pos, const T &value)
Definition: SLList.h:133
SortedList(void)
Definition: SortedList.h:38
Definition: SortedList.h:32
bool isEmpty(void) const
Definition: SLList.h:63
const T & first(void) const
Definition: SortedList.h:89
T & first(void)
Definition: SLList.h:119
Iterator(const SortedList &_list)
Definition: SortedList.h:62
Iterator find(const T &item) const
Definition: SLList.h:123
int count(void) const
Definition: SortedList.h:46
void removeAll(const CC< T > &items)
Definition: SortedList.h:84
void clear(void)
Definition: SLList.h:101
void removeFirst(void)
Definition: SortedList.h:42
void addLast(const T &value)
Definition: SLList.h:130
void removeLast(void)
Definition: SortedList.h:43
A::val_t val_t
Definition: SortedList.h:36
Definition: SortedList.h:59
A::key_t key_t
Definition: SortedList.h:35