template class Core::MutableVector

Overview

Base class for mutable vectors. More…

#include <corevector.h>

template <class T, class ResizePolicy>
class MutableVector: public Core::ConstVector
{
public:
    // methods

    void zeroFill();
    void fill(const T& data);
    bool add(const T& data);
    bool addOnce(const T& data);
    void addAll(const ConstVector<T>& other);
    void addAllOnce(const ConstVector<T>& other);
    bool remove(const T& data);
    bool removeAt(int idx);

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

    int removeIf(ContainerPredicateFunction recognize);
    bool removeFirst();
    bool removeLast();
    bool insertAt(int index, const T& data);
    void removeAll();
    void setCount(int _count);
    void empty();
    void sort();
    void sort(VectorCompareFunction function);
    void reverse();
    bool addSorted(const T& data);

    bool addSorted(
        const T& data,
        VectorCompareFunction function,
        bool reversed = false
    );

    bool swap(const T& t1, const T& t2);
    bool swapAt(int index1, int index2);
    MutableVector& operator << (const T& data);
};

// direct descendants

template <class T, int maxElements>
class FixedSizeVector;

template <class T>
class Vector;

Inherited Members

public:
    // methods

    bool isEmpty() const;
    INLINE int count() const;
    INLINE bool isValidIndex(int index) const;
    T& at(int idx) const;
    T& first() const;
    T& last() const;
    bool isEqual(const ConstVector<T>& other) const;
    bool operator == (const ConstVector& other) const;
    bool operator != (const ConstVector& other) const;
    int index(const T& data) const;
    int index(const T* item) const;
    bool contains(const T& data) const;
    bool containsAnyOf(const ConstVector<T>& other) const;
    T* search(const T& data) const;

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

    T* findIf(ContainerPredicateFunction recognize) const;
    INLINE T* getItems() const;
    INLINE operator T* () const;
    RangeIterator<ConstVector<T>, VectorIterator<T>, T&> begin() const;
    RangeIterator<ConstVector<T>, VectorIterator<T>, T&> end() const;
    static T& getError();

Detailed Documentation

Base class for mutable vectors.

Resizing is handled in derived classes.

Methods

void zeroFill()

Fill internal storage with zeros.

void fill(const T& data)

Fill internal storage with given data.

bool add(const T& data)

Add element.

bool addOnce(const T& data)

Add element once, i.e.

if not contained already.

void addAll(const ConstVector<T>& other)

Add all elements from other vector.

void addAllOnce(const ConstVector<T>& other)

Add all elements from other vector once (if not contained already).

bool remove(const T& data)

Remove equal element (if contained).

bool removeAt(int idx)

Remove element at index.

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.

bool removeFirst()

Remove first element.

bool removeLast()

Remove last element.

bool insertAt(int index, const T& data)

Insert element at given index.

void removeAll()

Remove all elements.

void setCount(int _count)

Set element count directly, only use if you know what you’re doing.

void empty()

Reset element count to zero, but keep capacity.

void sort()

Sort elements.

void sort(VectorCompareFunction function)

Sort elements.

Use DEFINE_VECTOR_COMPARE or DEFINE_VECTOR_COMPARE_OBJECT for function.

void reverse()

Reverse elements.

bool addSorted(const T& data)

Add element sorted.

bool addSorted(
    const T& data,
    VectorCompareFunction function,
    bool reversed = false
)

Add element sorted.

bool swap(const T& t1, const T& t2)

Swap elements.

bool swapAt(int index1, int index2)

Swap elements at index.

MutableVector& operator << (const T& data)

Add element (via operator).