Fw/DataStructures/docs/SizedContainer.md
SizedContainer is a class
defined in Fw/DataStructures.
It is an abstract class representing a sized container.
SizedContainer(const SizedContainer<T>& c)
Defined as = delete.
SizedContainer()
Use default initialization of members.
virtual ~SizedContainer()
Defined as = default.
SizedContainer& operator=(const SizedContainer&)
Defined as = delete.
virtual void clear() = 0
Clear the container.
Example:
void f(SizedContainer& c) {
c.clear();
ASSERT_EQ(c.getSize(), 0);
}
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);
}
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);
}
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());
}
}
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());
}
}