![]() |
Fréchet View
1.6.0
A Tool for Exploring Fréchet Distance Algorithms
|
An intrusive double-linked list, similar to boost::intrusive.
Link references are stored inside the element objects.
Simplifies a few things:
concatenating two lists is easy
Major restrictions apply: each element can only be part of one list. Shallow copies are not allowed. The list takes ownership of elements and deletes them on removal.
The implementation is not thread-safe.
Iterator methods (first,next,prev,last) are type-safe. but insertions are not type-safe (contrary to boost::intrusive classes).
Optionally, LinkedList can be circular, i.e. the last element is directly linked to the first element. This property can be modified an run-time.
Simply use T* for an iterator:
Modifications to the underlying list do not break the iterator (except when deleting the current object).
Concurrently iterating and deleting should be done like this:
T | element type; must derive from BLinkedListElement |
Definition at line 252 of file linkedlist.h.
#include <linkedlist.h>
Inherits frechet::data::BLinkedList.
Public Member Functions | |
LinkedList () | |
empty constructor; creates an empty list More... | |
LinkedList (LinkedList &&that) | |
move constructor; takes ownership of another list More... | |
template<typename Cloner > | |
LinkedList (const LinkedList &that, Cloner cloner) | |
deep copy constructor More... | |
LinkedList & | operator= (LinkedList &&that) |
move assigment operator More... | |
T * | first () const |
T * | last () const |
T * | remove (T *el) |
T * | operator[] (int i) const |
positional lookup (note: O(n), use with care) More... | |
void | swap (LinkedList< T > &that) |
exchange all elements with another list, taking ownership of the new elements More... | |
![]() | |
BLinkedList (bool circular=false) | |
default constructor; creates an empty list More... | |
BLinkedList (BLinkedList &&that) | |
move constructor More... | |
~BLinkedList () | |
destructor; releases all element objects More... | |
bool | empty () const |
int | size () const |
bool | circular () const |
void | setCircular (bool) |
update the circularity property of this list More... | |
BLinkedList & | operator= (BLinkedList &&that) |
move assigment operator More... | |
void | insert_first (BLinkedListElement *el) |
insert a new element at the beginning of the list; the list takes ownership of the element. Do not delete it yourself. More... | |
void | insert_last (BLinkedListElement *el) |
insert a new element at the end of the list; the list takes ownership of the element. Do not delete it yourself. More... | |
void | insert_before (BLinkedListElement *el, BLinkedListElement *before) |
insert a new element before a certain element of the list; the list takes ownership of the element. Do not delete it yourself. More... | |
void | insert_after (BLinkedListElement *el, BLinkedListElement *after) |
insert a new element after a certain element of the list; the list takes ownership of the element. Do not delete it yourself. More... | |
BLinkedListElement * | remove (BLinkedListElement *el) |
remove an element from the list and release its memory More... | |
void | clear () |
release all elements More... | |
int | concat (BLinkedList &that) |
append all elements of another list, taking ownership of the new elements More... | |
int | swap (BLinkedList &that) |
exchange all elements with another list, taking ownership of the new elements More... | |
Private Member Functions | |
BOOST_STATIC_ASSERT ((boost::is_base_of< BLinkedListElement, T >::value)) | |
Additional Inherited Members | |
![]() | |
BLinkedListElement * | operator[] (int i) const |
positional lookup (note: O(n), use with care) More... | |
![]() | |
BLinkedListElement * | _first |
the first element in the list (or nullptr) More... | |
BLinkedListElement * | _last |
the last element in the list (or nullptr) More... | |
int | _size |
current number of elements More... | |
bool | _circular |
if true, this is a circular list, i.e. the last element is connected to the first element More... | |
|
inline |
empty constructor; creates an empty list
Definition at line 256 of file linkedlist.h.
|
inline |
move constructor; takes ownership of another list
that | list to move elements from; will be empty on return |
Definition at line 259 of file linkedlist.h.
|
inline |
deep copy constructor
that | list to copy from |
cloner | a functor that creates deep copies of elements |
Cloner | a functor class that creates deep copies of elements |
Definition at line 268 of file linkedlist.h.
|
private |
|
inline |
Definition at line 292 of file linkedlist.h.
|
inline |
Definition at line 296 of file linkedlist.h.
|
inline |
move assigment operator
Note that there is no copy assigment operator because we must prevent shallow copies; double-linked elements must not be part of two separate lists.
that | list to move elements from; will be empty on return |
Definition at line 284 of file linkedlist.h.
|
inline |
positional lookup (note: O(n), use with care)
i | index in list |
Definition at line 305 of file linkedlist.h.
|
inline |
Definition at line 298 of file linkedlist.h.
|
inline |
exchange all elements with another list, taking ownership of the new elements
that | list to move elements from |
Definition at line 312 of file linkedlist.h.