Class Bag

java.lang.Object
com.graphbuilder.struc.Bag

public class Bag extends Object
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 Details

    • data

      protected Object[] data
    • size

      protected int size
  • Constructor Details

    • Bag

      public Bag()
    • Bag

      public Bag(int initialCapacity)
    • Bag

      public Bag(Object[] data, int size)
  • Method Details

    • add

      public void add(Object o)
    • size

      public int size()
    • setSize

      public void setSize(int s)
    • insert

      public void insert(Object o, int index)
    • ensureCapacity

      public void ensureCapacity(int capacity)
    • getCapacity

      public int getCapacity()
    • remove

      public int remove(Object o)
    • remove

      public Object remove(int index)
    • get

      public Object get(int index)
    • set

      public Object set(Object o, int index)
    • contains

      public boolean contains(Object o)
    • isEmpty

      public boolean isEmpty()
    • trimArray

      public void trimArray()
    • indexOf

      public int indexOf(Object o)
    • indexOf

      public int indexOf(Object o, int startIndex)
    • lastIndexOf

      public int lastIndexOf(Object o)
    • lastIndexOf

      public int lastIndexOf(Object o, int startIndex)