Class BucketList<Type>

java.lang.Object
  extended by BucketList<Type>
Type Parameters:
Type - the type of value stored in the buckets

public class BucketList<Type>
extends java.lang.Object

Class that implements a list of generic buckets.

Version:
9/25/16
Author:
Dave Reed

Constructor Summary
BucketList(int size)
          Constructs a list of empty buckets.
 
Method Summary
 void add(int bucketNum, Type newItem)
          Adds a new item to the specified bucket.
 java.util.ArrayList<Type> asList()
          Converts the bucket list to a single, flat list.
 void clear()
          Clears (makes empty) all of the buckets in the list.
 java.util.ArrayList<Type> getBucket(int bucketNum)
          Accesses the specified bucket (as a list).
 int numStored()
          Accesses the total number of items stored in the bucket list.
 int size()
          Accesses the size of the bucket list.
 
Methods inherited from class
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BucketList

public BucketList(int size)
Constructs a list of empty buckets.

Parameters:
size - the number of empty buckets in the list
Method Detail

add

public void add(int bucketNum,
                Type newItem)
Adds a new item to the specified bucket.

Parameters:
bucketNum - the bucket number (starting at 0)
newItem - the item to be added

asList

public java.util.ArrayList<Type> asList()
Converts the bucket list to a single, flat list.

Returns:
the contents of the buckets, in order, in a list

clear

public void clear()
Clears (makes empty) all of the buckets in the list.


getBucket

public java.util.ArrayList<Type> getBucket(int bucketNum)
Accesses the specified bucket (as a list).

Parameters:
bucketNum - the bucket number (starting at 0)
Returns:
a list of the bucket contents

numStored

public int numStored()
Accesses the total number of items stored in the bucket list.

Returns:
total number of items stored in all the buckets

size

public int size()
Accesses the size of the bucket list.

Returns:
the number of buckets in the list