template class Core::LinkedList

Overview

Double-linked list container class. More…

#include <corelinkedlist.h>

template <class T>
class LinkedList
{
public:
    // methods

    void append (const T& data);
    void prepend (const T& data);
    bool insertBefore (const T& before, const T& data);
    bool insertBefore (ListIterator <T>& iter, const T& data);
    bool insertAfter (ListIterator <T>& iter, const T& data);
    bool insertAt (int idx, const T& data);
    bool addSorted (const T& data);
    bool replace (ListIterator <T>& iter, const T& newData);
    void swapContent (LinkedList <T>& other);
    bool remove (const T& data);
    bool removeAt (int idx);
    bool remove (ListIterator <T>& iter);

    template  <class Predicate>
    int removeIf (const Predicate& recognize);

    int removeIf (ContainerPredicateFunction recognize);
    void removeAll ();
    T removeFirst ();
    T removeLast ();
    bool isEmpty () const;
    bool isMultiple () const;
    int count () const;
    void sort ();

    template  <class Predicate>
    void sort (Predicate greater);

    const T& at (int idx) const;
    bool contains (const T& data) const;
    const T& lookup (const T& data) const;
    const T& getFirst () const;
    const T& getLast () const;

    template  <class Predicate>
    const T& findIf (const Predicate& recognize) const;

    const T& findIf (ContainerPredicateFunction recognize) const;
    RangeIterator <LinkedList <T>, ListIterator <T>, T&> begin () const;
    RangeIterator <LinkedList <T>, ListIterator <T>, T&> end () const;
};

Detailed Documentation

Double-linked list container class.

Methods

void append (const T& data)

Append list element.

void prepend (const T& data)

Prepend list element.

bool insertBefore (const T& before, const T& data)

Insert before existing element.

bool insertBefore (ListIterator <T>& iter, const T& data)

Insert before previous element.

bool insertAfter (ListIterator <T>& iter, const T& data)

Insert after previous element.

bool insertAt (int idx, const T& data)

Insert element at index.

bool addSorted (const T& data)

Add element sorted.

bool replace (ListIterator <T>& iter, const T& newData)

Replace previous element.

void swapContent (LinkedList <T>& other)

Swap content with other list.

bool remove (const T& data)

Remove element.

bool removeAt (int idx)

Remove element at index.

bool remove (ListIterator <T>& iter)

Remove previous element.

template  <class Predicate>
int removeIf (const Predicate& recognize)

Remove elements if condition is met.

predicate: (T&) -> bool

int removeIf (ContainerPredicateFunction recognize)

Remove elements if condition is met.

Use DEFINE_CONTAINER_PREDICATE.

void removeAll ()

Remove all elements.

T removeFirst ()

Remove first element.

T removeLast ()

Remove last element.

bool isEmpty () const

Check if container is empty.

bool isMultiple () const

Check if container holds more than one element.

int count () const

Count elements in container.

void sort ()

Sort elements in container.

template  <class Predicate>
void sort (Predicate greater)

Sort elements in container with custom predicate.

predicate: (const T& a, const T& b) -> a > b

const T& at (int idx) const

Get element at index.

bool contains (const T& data) const

Check if container holds given data.

const T& lookup (const T& data) const

Lookup element with same data.

const T& getFirst () const

Get first element.

const T& getLast () const

Get last element.

template  <class Predicate>
const T& findIf (const Predicate& recognize) const

Find element based on predicate.

predicate: (T&) -> bool

const T& findIf (ContainerPredicateFunction recognize) const

Find element based on predicate.

Use DEFINE_CONTAINER_PREDICATE.