Class Array<Item>

java.lang.Object
dsa.lib.DSAObject
dsa.lab01.exercises.Array<Item>
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
    Constructor
    Description
    Construct an empty array.
    Array(Item... items)
    Construct an array containing the given items.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(Item item)
    Check if the given item is equal to any of those contained.
    int
    Get the number of contained items.
    toString(String indent)
     

    Methods inherited from class dsa.lib.DSAObject

    toDebugString, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface dsa.lab01.base.Container

    isEmpty
  • Constructor Details

    • Array

      public Array()
      Construct an empty array.
    • Array

      @SafeVarargs public Array(Item... items)
      Construct an array containing the given items.
      Parameters:
      items - the items
  • Method Details

    • size

      public int size()
      Description copied from interface: Container
      Get the number of contained items.
      Specified by:
      size in interface Container<Item>
      Returns:
      the size
    • contains

      public boolean contains(Item item)
      Description copied from interface: Container
      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

      public String toString(String indent)
      Specified by:
      toString in interface dsa.lib.DSAInterface