Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
frechet::data::BLinkedList Class Reference

Detailed Description

abstract base class for LinkedList

Definition at line 76 of file linkedlist.h.

#include <linkedlist.h>

Inherited by frechet::data::LinkedList< T >, and frechet::data::LinkedList< BoundarySegment >.

Public Member Functions

 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...
 
BLinkedListoperator= (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...
 
BLinkedListElementremove (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...
 

Protected Member Functions

BLinkedListElementoperator[] (int i) const
 positional lookup (note: O(n), use with care) More...
 

Protected Attributes

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...
 

Private Member Functions

void dispose ()
 release all elements and update anchors More...
 
void releaseAll ()
 release all elements More...
 
 BLinkedList (const BLinkedList &)
 copy constructor. do not use. More...
 
BLinkedListoperator= (const BLinkedList &)
 copy assigment operator. do not use. More...
 

Constructor & Destructor Documentation

◆ BLinkedList() [1/3]

BLinkedList::BLinkedList ( bool  circular = false)

default constructor; creates an empty list

Parameters
circularmake this list circular (optional)

Definition at line 16 of file linkedlist.cpp.

◆ BLinkedList() [2/3]

BLinkedList::BLinkedList ( BLinkedList &&  that)

move constructor

Note that there is no copy constructor because we must prevent shallow copies; double-linked elements must not be part of two separate lists.

Parameters
thatlist to move elements from; will be empty on return

Definition at line 20 of file linkedlist.cpp.

◆ ~BLinkedList()

BLinkedList::~BLinkedList ( )

destructor; releases all element objects

Definition at line 29 of file linkedlist.cpp.

◆ BLinkedList() [3/3]

frechet::data::BLinkedList::BLinkedList ( const BLinkedList )
inlineprivate

copy constructor. do not use.

Definition at line 198 of file linkedlist.h.

Member Function Documentation

◆ circular()

bool frechet::data::BLinkedList::circular ( ) const
Returns
true if the list is circular

◆ clear()

void BLinkedList::clear ( )

release all elements

Definition at line 138 of file linkedlist.cpp.

◆ concat()

int BLinkedList::concat ( BLinkedList that)

append all elements of another list, taking ownership of the new elements

Parameters
thatlist to move elements from; will be empty on return
Returns
size of the list after appending

Definition at line 145 of file linkedlist.cpp.

◆ dispose()

void BLinkedList::dispose ( )
private

release all elements and update anchors

Definition at line 174 of file linkedlist.cpp.

◆ empty()

bool BLinkedList::empty ( ) const
Returns
true if the list is empty

Definition at line 31 of file linkedlist.cpp.

◆ insert_after()

void BLinkedList::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.

Parameters
ela new element
afterplace to insert the new element after

Definition at line 82 of file linkedlist.cpp.

◆ insert_before()

void BLinkedList::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.

Parameters
ela new element
beforeplace to insert the new element before

Definition at line 65 of file linkedlist.cpp.

◆ insert_first()

void BLinkedList::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.

Parameters
ela new element

Definition at line 39 of file linkedlist.cpp.

◆ insert_last()

void BLinkedList::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.

Parameters
ela new element

Definition at line 52 of file linkedlist.cpp.

◆ operator=() [1/2]

BLinkedList & BLinkedList::operator= ( BLinkedList &&  that)

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.

Parameters
thatlist to move elements from; will be empty on return
Returns
this list, containing the elements from 'that'

Definition at line 197 of file linkedlist.cpp.

◆ operator=() [2/2]

BLinkedList& frechet::data::BLinkedList::operator= ( const BLinkedList )
inlineprivate

copy assigment operator. do not use.

Definition at line 200 of file linkedlist.h.

◆ operator[]()

BLinkedListElement * BLinkedList::operator[] ( int  i) const
protected

positional lookup (note: O(n), use with care)

Parameters
iindex in list
Returns
the i-th element, or nullptr

Definition at line 183 of file linkedlist.cpp.

◆ releaseAll()

void BLinkedList::releaseAll ( )
private

release all elements

Definition at line 207 of file linkedlist.cpp.

◆ remove()

BLinkedListElement * BLinkedList::remove ( BLinkedListElement el)

remove an element from the list and release its memory

Parameters
elan element, which must be part of this list
Returns
the successor of the deleted element (may be nullptr)

Definition at line 115 of file linkedlist.cpp.

◆ setCircular()

void BLinkedList::setCircular ( bool  circ)

update the circularity property of this list

Definition at line 99 of file linkedlist.cpp.

◆ size()

int BLinkedList::size ( ) const
Returns
number of elements

Definition at line 37 of file linkedlist.cpp.

◆ swap()

int BLinkedList::swap ( BLinkedList that)

exchange all elements with another list, taking ownership of the new elements

Parameters
thatlist to move elements from
Returns
size of the list after swap

Definition at line 165 of file linkedlist.cpp.

Member Data Documentation

◆ _circular

bool frechet::data::BLinkedList::_circular
protected

if true, this is a circular list, i.e. the last element is connected to the first element

Definition at line 85 of file linkedlist.h.

◆ _first

BLinkedListElement* frechet::data::BLinkedList::_first
protected

the first element in the list (or nullptr)

Definition at line 79 of file linkedlist.h.

◆ _last

BLinkedListElement* frechet::data::BLinkedList::_last
protected

the last element in the list (or nullptr)

Definition at line 81 of file linkedlist.h.

◆ _size

int frechet::data::BLinkedList::_size
protected

current number of elements

Definition at line 83 of file linkedlist.h.


The documentation for this class was generated from the following files: