20 #ifndef __OpenKarto_List_h__ 21 #define __OpenKarto_List_h__ 111 virtual void Add(
const T& rValue)
171 message.
Append(
"Cannot remove item: invalid index: ");
252 return (*
this)[index];
262 return (*
this)[index];
270 inline T*
Find(
const T& rValue)
338 T* pElements =
new T[newSize];
343 for (
kt_size_t i = 0; i < smallerSize; i++)
365 if (newCapacity > oldSize)
395 else if (comparison < 0)
535 throw Exception(
"Cannot create iterator: List is NULL");
545 return m_Index < m_pList->Size();
554 if (m_Index < m_pList->
Size())
557 return m_pList->Get(m_Index - 1);
560 throw Exception(
"Cannot increment iterator: No more items in iterator.");
569 if (m_Index < m_pList->
Size())
571 return m_pList->Get(m_Index);
574 throw Exception(
"Cannot dereference iterator: No more items in iterator.");
583 if (m_Index < m_pList->
Size())
585 return &m_pList->Get(m_Index);
588 throw Exception(
"Cannot dereference iterator: No more items in iterator.");
628 throw Exception(
"Iterators are not operating on the same list");
631 return m_Index != rOther.
m_Index;
660 throw Exception(
"Cannot create iterator: List is NULL");
670 return m_Index < m_pList->Size();
679 if (m_Index < m_pList->
Size())
682 return m_pList->Get(m_Index - 1);
685 throw Exception(
"Cannot increment iterator: No more items in iterator.");
693 if (m_Index < m_pList->
Size())
695 m_pList->RemoveAt(m_Index);
698 throw Exception(
"Cannot erase item: No more items in iterator.");
707 if (m_Index < m_pList->
Size())
709 return m_pList->Get(m_Index);
712 throw Exception(
"Cannot dereference iterator: No more items in iterator.");
721 if (m_Index < m_pList->
Size())
723 return &m_pList->Get(m_Index);
726 throw Exception(
"Cannot dereference iterator: No more items in iterator.");
766 throw Exception(
"Iterators are not operating on the same list");
769 return m_Index != rOther.
m_Index;
780 #endif // __OpenKarto_List_h__ void Set(kt_size_t index, const T &rValue)
virtual kt_bool HasNext() const
void Append(const String &rString)
virtual kt_size_t Size() const
virtual const T & Back() const
virtual kt_bool HasNext() const
T & operator[](kt_size_t index)
virtual const T & Front() const
virtual T & Get(kt_size_t index)
virtual void Resize(kt_size_t newSize)
const List< T > * m_pList
const T & operator[](kt_size_t index) const
virtual void Add(const T &rValue)
virtual const T & Get(kt_size_t index) const
virtual kt_bool Remove(const T &rValue)
T * Find(const T &rValue)
virtual void RemoveAt(kt_size_t index)
virtual const T & operator*() const
virtual ConstListIterator< T > GetConstIterator() const
void EnsureCapacity(kt_size_t newCapacity)
kt_bool operator==(const List &rOther) const
virtual const T * operator->() const
virtual kt_bool IsEmpty() const
virtual ListIterator< T > GetIterator()
virtual const ListIterator & operator=(const ListIterator &rOther)
static String ToString(const char *value)
virtual T operator++(int)
virtual void Add(const List &rValue)
const T & Minimum(const T &value1, const T &value2)
ListIterator(List< T > *pList)
virtual kt_bool Contains(const T &rValue) const
ConstListIterator< T > ConstIterator
virtual const T & operator++()
kt_int32s BinarySearch(const T &rValue, kt_int32s(*f)(const T &a, const T &b))
virtual T & operator*() const
ListIterator< T > Iterator
virtual kt_bool operator!=(const ListIterator &rOther) const
virtual T * operator->() const
List & operator=(const List &rOther)
virtual T operator++(int)
virtual kt_bool operator!=(const ConstListIterator &rOther) const
virtual const T & operator++()
ConstListIterator(const List< T > *pList)
virtual const ConstListIterator & operator=(const ConstListIterator &rOther)