template<class element_t> class adevs_bag

An bag stores a collection of elements.

Inheritance:


Public Methods

[more] adevs_bag()
[more] adevs_bag(int capacity, int grow = BAG_DEFAULT_GROW)
Capacity is the initial memory set aside to hold elements.
[more] adevs_bag(const adevs_bag<element_t>& src)
Element copying is done via the assignment operator
[more]const adevs_bag<element_t> & operator=(const adevs_bag<element_t>& src)
Element copying is done via the assignment operator
[more]int getSize() const
The last index is at size - 1
[more]int getCapacity() const
Reports the current capacity of the data structure
[more]void enlarge(int adjustment)
Increases the capacity by adjustment value
[more]element_t& operator[](int index)
Returns a reference to the object stored at index
[more]const element_t& get(int index) const
Returns a constant reference to the element stored at index
[more]void swap(int i, int j)
Swaps the elements at index i and j
[more]void append(const adevs_bag<element_t>& src)
Appends the items in the source adevs_bag to this adevs_bag
[more]virtual void removeAll()
Removes all elements from the adevs_bag
[more]virtual void add(const element_t& e)
Adds an element to the end of the adevs_bag (last index)
[more]virtual void remove(int index)
Removes the element at the indicated index
[more]void erase(const element_t& e)
Find and erase the first element equal to e (as per the == operator)
[more]virtual ~adevs_bag()


Documentation

An bag stores a collection of elements. It supports indexed access to the elements (via the [] operator), addition of new elements, and removal of elements. The element type must support the assignment and equality operators.

New elements are appended to the end of the bag. When an element is removed, the last element of the bag fills the vacant slot, thereby avoiding holes in the indexing.

o adevs_bag()

o adevs_bag(int capacity, int grow = BAG_DEFAULT_GROW)
Capacity is the initial memory set aside to hold elements. When the adevs_bag becomes full, its capacity is increased by grow slots.

o adevs_bag(const adevs_bag<element_t>& src)
Element copying is done via the assignment operator

oconst adevs_bag<element_t> & operator=(const adevs_bag<element_t>& src)
Element copying is done via the assignment operator

oint getSize() const
The last index is at size - 1

oint getCapacity() const
Reports the current capacity of the data structure

ovoid enlarge(int adjustment)
Increases the capacity by adjustment value

oelement_t& operator[](int index)
Returns a reference to the object stored at index

oconst element_t& get(int index) const
Returns a constant reference to the element stored at index

ovoid swap(int i, int j)
Swaps the elements at index i and j

ovoid append(const adevs_bag<element_t>& src)
Appends the items in the source adevs_bag to this adevs_bag

ovirtual void removeAll()
Removes all elements from the adevs_bag

ovirtual void add(const element_t& e)
Adds an element to the end of the adevs_bag (last index)

ovirtual void remove(int index)
Removes the element at the indicated index

ovoid erase(const element_t& e)
Find and erase the first element equal to e (as per the == operator)

ovirtual ~adevs_bag()


Direct child classes:
adevs_set

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.