Elm
2
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. |
References list< T >::cons(), list< T >::hd(), list< T >::isEmpty(), and list< T >::tl().
Referenced by elm::imm::operator+().
Build a new list by prepending h to t.
h | Item to prepend. |
t | List to use as tail. |
Referenced by list< T >::concat(), elm::imm::cons(), and list< T >::remove().
|
inline |
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. |
Test if the current list and l are equals.
l | List to compare. |
References list< T >::hd(), and list< T >::tl().
Referenced by list< T >::operator!=(), and list< T >::operator==().
|
inline |
Get the first item of the list.
Referenced by list< T >::concat(), sorted_list< T, K, C >::contains(), list< T >::equals(), list< T >::operator*(), elm::imm::operator<<(), and list< T >::remove().
Test if the list is empty.
Referenced by list< T >::concat(), and list< T >::operator bool().
References list< T >::isEmpty().
References list< T >::equals().
|
inline |
References list< T >::hd().
References list< T >::equals().
|
inline |
Build a new list without the first instance of h.
h | Item to remove. |
References list< T >::cons(), list< T >::hd(), and list< T >::tl().
Get the sub-list after the first item in the list.
Referenced by list< T >::concat(), sorted_list< T, K, C >::contains(), list< T >::equals(), elm::imm::operator<<(), and list< T >::remove().
|
static |