template class Core::Vector

Overview

One-dimensional array that grows dynamically. More…

#include <corevector.h>

template <class T>
class Vector: public Core::MutableVector
{
public:
    // construction

    Vector(int capacity = 0, int delta = 5);
    Vector(const Vector& other);

    // methods

    void copyVector(const Vector& other);
    void copyVector(const T vector[], int count);
    void takeVector(Vector& other);
    Vector& operator = (const Vector& other);
    bool resize(int capacity);
    void setDelta(int delta);
    int getDelta() const;
    int getCapacity() const;
};

// direct descendants

class DeletableList;
class FormatterRegistryList;
class InterpolatorClassList;
class ProductBundle;

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();
    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);

Detailed Documentation

One-dimensional array that grows dynamically.

Construction

Vector(int capacity = 0, int delta = 5)

Construct with initial capacity and delta.

Vector(const Vector& other)

Copy constructor.

Methods

void copyVector(const Vector& other)

Copy from other vector.

void copyVector(const T vector[], int count)

Copy from other vector.

void takeVector(Vector& other)

Take over memory from other vector.

bool resize(int capacity)

Resizes internal memory to capacity, rounded up to the next multiple of delta.

void setDelta(int delta)

Set delta applied on resize.

int getDelta() const

Get configured delta.

int getCapacity() const

Get current capacity.