Package com.graphbuilder.struc
Class Bag
java.lang.Object
com.graphbuilder.struc.Bag
Bag is a container of objects using an array. The Bag is designed to be as light weight as possible.
It only contains a reference to an array and a size counter. In methods that accept both an Object and
an int as parameters, the Object is always specified first.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanvoidensureCapacity(int capacity) get(int index) intintintvoidbooleanisEmpty()intintlastIndexOf(Object o, int startIndex) remove(int index) intvoidsetSize(int s) intsize()void
-
Field Details
-
data
-
size
protected int size
-
-
Constructor Details
-
Bag
public Bag() -
Bag
public Bag(int initialCapacity) -
Bag
-
-
Method Details
-
add
-
size
public int size() -
setSize
public void setSize(int s) -
insert
-
ensureCapacity
public void ensureCapacity(int capacity) -
getCapacity
public int getCapacity() -
remove
-
remove
-
get
-
set
-
contains
-
isEmpty
public boolean isEmpty() -
trimArray
public void trimArray() -
indexOf
-
indexOf
-
lastIndexOf
-
lastIndexOf
-