Skip to content

SizedContainer

SizedContainer is a class defined in Fw/DataStructures. It is an abstract class representing a sized container.

1. Private Constructors

1.1. Copy Constructor

SizedContainer(const SizedContainer<T>& c)

Defined as = delete.

2. Protected Constructors and Destructors

2.1. Zero-Argument Constructor

SizedContainer()

Use default initialization of members.

2.2. Destructor

virtual ~SizedContainer()

Defined as = default.

3. Private Member Functions

3.1. operator=

SizedContainer& operator=(const SizedContainer&)

Defined as = delete.

4. Public Member Functions

4.1. clear

virtual void clear() = 0

Clear the container.

Example:

void f(SizedContainer& c) {
    c.clear();
    ASSERT_EQ(c.getSize(), 0);
}

4.2. getCapacity

virtual FwSizeType getCapacity() const = 0

Return the current capacity.

Example:

void f(const SizedContainer& c) {
    const auto size = c.getSize();
    const auto capacity = c.getCapacity();
    ASSERT_LE(size, capacity);
}

4.3. getSize

virtual FwSizeType getSize() const = 0

Return the current size.

Example:

void f(const SizedContainer& c) {
    c.clear();
    auto size = c.getSize();
    ASSERT_EQ(size, 0);
}

4.4. isEmpty

bool isEmpty() const

Return true if the container is empty.

Example:

void f(const SizedContainer& c) {
    if (c.size() == 0) {
        ASSERT_TRUE(c.isEmpty());
    } else {
        ASSERT_FALSE(c.isEmpty());
    }
}

4.5. isFull

bool isFull() const

Return true if the container is full.

Example:

void f(const SizedContainer& c) {
    if (c.size() >= c.capacity()) {
        ASSERT_TRUE(c.isFull());
    } else {
        ASSERT_FALSE(c.isFull());
    }
}