38 #ifndef BLOCXX_LIST_HPP_INCLUDE_GUARD_ 39 #define BLOCXX_LIST_HPP_INCLUDE_GUARD_ 40 #include "blocxx/BLOCXX_config.h" 48 template<
class T>
class List;
54 inline bool operator<(const List<T>& x,
const List<T>& y);
60 template<
class T>
class List 63 typedef std::list<T>
L;
86 explicit List(L* toWrap) : m_impl(toWrap)
94 template<
class InputIterator>
95 List(InputIterator first, InputIterator last)
96 : m_impl(new L(first, last))
106 List(size_type n,
const T& value) : m_impl(new L(n, value))
116 List(
int n,
const T& value) : m_impl(new L(n, value))
126 List(
long n,
const T& value) : m_impl(new L(n, value))
134 explicit List(size_type n) : m_impl(new L(n))
152 return m_impl->begin();
161 return m_impl->begin();
170 return m_impl->end();
177 const_iterator
end()
const 179 return m_impl->end();
188 return m_impl->rbegin();
197 return m_impl->rbegin();
206 return m_impl->rend();
213 const_reverse_iterator
rend()
const 215 return m_impl->rend();
222 return m_impl->empty();
229 return m_impl->size();
236 return m_impl->max_size();
243 return m_impl->front();
250 return m_impl->front();
257 return m_impl->back();
264 return m_impl->back();
282 iterator
insert(iterator position,
const T& x)
284 return m_impl->insert(position, x);
295 return m_impl->insert(position);
304 template<
class InputIterator>
305 void insert(iterator position, InputIterator first, InputIterator last)
307 m_impl->insert(position, first, last);
318 void insert(iterator pos, size_type n,
const T& x)
320 m_impl->insert(pos, n, x);
331 void insert(iterator pos,
int n,
const T& x)
333 m_impl->insert(pos, n, x);
344 void insert(iterator pos,
long n,
const T& x)
346 m_impl->insert(pos, n, x);
355 m_impl->push_front(x);
364 m_impl->push_back(x);
375 return m_impl->erase(position);
386 iterator
erase(iterator first, iterator last)
388 return m_impl->erase(first, last);
396 void resize(size_type new_size,
const T& x)
398 m_impl->resize(new_size, x);
408 m_impl->resize(new_size);
427 const_iterator
find(
const T &x, const_iterator first,
428 const_iterator last)
const 430 for( ; first !=
end(); ++first)
445 const_iterator
find(
const T &x)
const 458 iterator
find(
const T &x, iterator first, iterator last)
460 for( ; first !=
end(); ++first)
489 const_iterator last)
const 491 return find(x, first, last) !=
end();
524 m_impl->splice(position, *x.
m_impl);
536 m_impl->splice(position, *x.
m_impl, i);
547 void splice(iterator position,
List& x, iterator first, iterator last)
549 m_impl->splice(position, *x.
m_impl, first, last);
555 void remove(
const T& value)
557 m_impl->remove(value);
596 m_impl->remove_if (p);
603 template<
class BinaryPredicate>
void unique(BinaryPredicate bp)
614 m_impl->merge(*x.
m_impl, swo);
648 inline bool operator<(const List<T>& x,
const List<T>& y)
650 return *x.
m_impl < *y.m_impl;
660 return new std::list<T>(*obj);
L::const_iterator const_iterator
L::difference_type difference_type
const_iterator end() const
iterator find(const T &x)
Find element x in the list.
void merge(List &x)
Merge the current and specified lists, producing a combined list that is ordered with respect to the ...
void splice(iterator position, List &x, iterator first, iterator last)
Move the elements from list x specified by first and last iterators into the current list at the give...
iterator erase(iterator position)
Remove an element from the List specified with an iterator.
List(L *toWrap)
Constructor.
void clear()
Remove all items from the List.
iterator insert(iterator position)
Insert an default-constructed element to the List before the element specified by the iterator...
void unique()
Remove all duplicate elements from the List.
bool contains(const T &x) const
Determine if element x is contained in the list.
void splice(iterator position, List &x)
Move the specified list into the current list at the given position.
List(InputIterator first, InputIterator last)
Construct a List from a range specified with InputIterators.
void insert(iterator pos, long n, const T &x)
Insert a specified number of elements that are copies of a given object before the given position in ...
void sort()
Sort the list using the < operator to compare elements.
const_reverse_iterator rbegin() const
L::const_reverse_iterator const_reverse_iterator
void swap(List< T > &x)
Exchanges the elements of the current list with those of another.
void swap(COWReference< T > &arg)
iterator insert(iterator position, const T &x)
Insert an element to the List before the element specified by the iterator.
const_iterator find(const T &x, const_iterator first, const_iterator last) const
Find element x in the list range specified by the first and last iterators.
friend bool operator==(const List< T > &x, const List< T > &y)
Determine equality of two Lists comparing the size of both lists and all elements in the same positio...
void merge(List &x, StrictWeakOrdering swo)
Merge the current and specified list, producing a combined list that is ordered with respect to the s...
const_reference front() const
void remove_if(Predicate p)
Removes all elements from the list for which the unary predicate p is true.
List(long n, const T &value)
Construct a List that consist of a specified number of elements that are copies of a given object...
void resize(size_type new_size, const T &x)
Ensure the List has a given size.
List(int n, const T &value)
Construct a List that consist of a specified number of elements that are copies of a given object...
void sort(StrictWeakOrdering swo)
Sort the list using the specified comparisation class.
List(size_type n, const T &value)
Construct a List that consist of a specified number of elements that are copies of a given object...
List()
Default Constructor.
void insert(iterator pos, size_type n, const T &x)
Insert a specified number of elements that are copies of a given object before the given position in ...
reverse_iterator rbegin()
void pop_back()
Remove the last element in the List.
iterator find(const T &x, iterator first, iterator last)
Find element x in the list range specified by the first and last iterators.
void insert(iterator pos, int n, const T &x)
Insert a specified number of elements that are copies of a given object before the given position in ...
L::reverse_iterator reverse_iterator
void push_front(const T &x)
Prepend the specified element at the front of the List.
bool operator==(const Array< T > &x, const Array< T > &y)
const_reverse_iterator rend() const
bool contains(const T &x, const_iterator first, const_iterator last) const
Determine if element x is contained in the list range specified by the first and last iterators...
L::const_reference const_reference
bool StrictWeakOrdering(const T1 &lhs1, const T1 &rhs1)
void insert(iterator position, InputIterator first, InputIterator last)
Insert a range of elements before a given position in the List.
void pop_front()
Remove the first element in the List.
void push_back(const T &x)
Append the specified element to the end of the List.
This class is a wrapper around std::list<> and adds COW capabilities.
void resize(size_type new_size)
Ensure the List has a given size appending a default-constructed object to the end of the List if it ...
size_type max_size() const
const_iterator begin() const
iterator erase(iterator first, iterator last)
Remove elements from the List specified by a beginning and ending iterator.
L::const_pointer const_pointer
T * COWReferenceClone(T *obj)
void reverse()
Reverse the order of elements in the list.
void splice(iterator position, List &x, iterator i)
Move the specified element from list x pointed to by iterator i into the current list at the given po...
const_reference back() const
void unique(BinaryPredicate bp)
Remove all elements from the List for which the binary predicate bp is true.
List(size_type n)
Construct a List that consist of a specified number of elements that have be constructed using the de...
const_iterator find(const T &x) const
Find element x in the list.