Elm
1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/imm/list.h>
Classes | |
class | Collector |
Public Member Functions | |
list (void) | |
list (const list< T > &l) | |
list< T > & | operator= (list< T > l) |
const T & | hd (void) const |
list< T > | tl (void) const |
const T & | operator* (void) const |
bool | isEmpty (void) const |
operator bool (void) const | |
int | length (void) const |
bool | contains (const T &v) |
bool | equals (list< T > l) const |
bool | operator== (list< T > l) const |
bool | operator!= (list< T > l) const |
list< T > | concat (list< T > l) |
list< T > | remove (const T &h) |
Static Public Member Functions | |
static void | add (Collector &coll) |
static void | remove (Collector &coll) |
static list< T > | cons (const T &h, list< T > t) |
Static Public Attributes | |
static list< T > | null |
Implementation of immutable and garbage collected list.
As C++ does not allow to implement easily and efficiently a garbage collector, the user of this class is responsible to provided its own collector using the function list<T>::add(object) with object inheriting from list<T>::Collector and implementing the member function list<T>::Collector::collect(). This function must call mark() for each list in use as in the example below:
T | Type of items in the list. |
elm::imm::list< T >::list | ( | void | ) |
Build an empty list.
elm::imm::list< T >::list | ( | const list< T > & | l | ) |
Clone a list.
|
static |
list<T> elm::imm::list< T >::concat | ( | list< T > | l | ) |
References elm::imm::list< T >::cons(), elm::imm::list< T >::hd(), elm::imm::list< T >::isEmpty(), and elm::imm::list< T >::tl().
Referenced by elm::imm::operator+().
|
static |
Build a new list by prepending h to t.
h | Item to prepend. |
t | List to use as tail. |
Referenced by elm::imm::list< T >::concat(), elm::imm::cons(), and elm::imm::list< T >::remove().
bool elm::imm::list< T >::contains | ( | const T & | v | ) |
Test if v is in the list. The Equiv<T> is used to perform the test of equality. Therefore, a user can provide its own implementation of Equiv<T> to change the usual behavior of the equality tests.
v | Item to test. |
bool elm::imm::list< T >::equals | ( | list< T > | l | ) | const |
Test if the current list and l are equals.
l | List to compare. |
References elm::imm::list< T >::hd(), and elm::imm::list< T >::tl().
Referenced by elm::imm::list< T >::operator!=(), and elm::imm::list< T >::operator==().
const T & elm::imm::list< T >::hd | ( | void | ) | const |
Get the first item of the list.
Referenced by elm::imm::list< T >::concat(), elm::imm::sorted_list< T, K, C >::contains(), elm::imm::list< T >::equals(), elm::imm::list< T >::operator*(), and elm::imm::list< T >::remove().
bool elm::imm::list< T >::isEmpty | ( | void | ) | const |
Test if the list is empty.
Referenced by elm::imm::list< T >::concat(), and elm::imm::list< T >::operator bool().
int elm::imm::list< T >::length | ( | void | ) | const |
Compute the length of the list.
elm::imm::list< T >::operator bool | ( | void | ) | const |
References elm::imm::list< T >::isEmpty().
bool elm::imm::list< T >::operator!= | ( | list< T > | l | ) | const |
References elm::imm::list< T >::equals().
const T& elm::imm::list< T >::operator* | ( | void | ) | const |
References elm::imm::list< T >::hd().
list<T>& elm::imm::list< T >::operator= | ( | list< T > | l | ) |
bool elm::imm::list< T >::operator== | ( | list< T > | l | ) | const |
References elm::imm::list< T >::equals().
|
static |
list< T > elm::imm::list< T >::remove | ( | const T & | h | ) |
Build a new list without the first instance of h.
h | Item to remove. |
References elm::imm::list< T >::cons(), elm::imm::list< T >::hd(), and elm::imm::list< T >::tl().
list< T > elm::imm::list< T >::tl | ( | void | ) | const |
Get the sub-list after the first item in the list.
Referenced by elm::imm::list< T >::concat(), elm::imm::sorted_list< T, K, C >::contains(), elm::imm::list< T >::equals(), and elm::imm::list< T >::remove().
|
static |