- Type Parameters:
Item - the item type
- All Implemented Interfaces:
Container<Item>, dsa.lib.DSAInterface
public class Array<Item>
extends dsa.lib.DSAObject
implements Container<Item>
An array-based container.
Contains some number of items using an array.
-
Constructor Summary
Constructors
Construct an empty array.
Construct an array containing the given items.
-
Method Summary
boolean
Check if the given item is equal to any of those contained.
int
Get the number of contained items.
Methods inherited from class dsa.lib.DSAObject
toDebugString, toString
-
Constructor Details
-
Array
public Array()
Construct an empty array.
-
Array
Construct an array containing the given items.
- Parameters:
items - the items
-
Method Details
-
size
public int size()
Get the number of contained items.
- Specified by:
size in interface Container<Item>
- Returns:
- the size
-
contains
public boolean contains(Item item)
Check if the given item is equal to any of those contained.
- Specified by:
contains in interface Container<Item>
- Parameters:
item - the item to check for membership
- Returns:
- whether such an item is contained
-
toString
- Specified by:
toString in interface dsa.lib.DSAInterface