net.sourceforge.chaperon.common
Class IntegerList

java.lang.Object
  extended by net.sourceforge.chaperon.common.IntegerList
All Implemented Interfaces:
IntegerCollection

public class IntegerList
extends java.lang.Object
implements IntegerCollection

This class represents a list of integers values.

Version:
CVS $Id: IntegerList.java,v 1.4 2003/12/09 19:55:52 benedikta Exp $
Author:
Stephan Michels

Constructor Summary
IntegerList()
          Constructs a empty list of integer values.
 
Method Summary
 int add(int value)
          Add a value to the list.
 void add(int[] array)
          Add the values of an array to this list.
 void add(IntegerCollection collection)
          Add a collection of values to this list.
 void clear()
          Removes all values from this list.
 boolean contains(int value)
          If the list contains a value.
 int get(int index)
          Return a value from this list given by an index.
 int getCount()
          Returns the count of values in this list
 int indexOf(int value)
          Return the index of a value, otherwise -1.
 boolean isEmpty()
          If this list contains no values.
 int peek()
          Peek a value of the end of this list.
 int pop()
          Pops a value of the end of this list.
 void push(int value)
          Pushs a value on top to this list
 void push(int[] values)
          Push values from an array.
 void remove(int index)
          Removes a value giving by an index.
 void removeValue(int value)
          Removes a value from this list.
 void set(int index, int value)
          Replace a value given by an index.
 void swap(int index1, int index2)
          Swaps two values from this list.
 java.lang.String toString()
          Return a string representation of the collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntegerList

public IntegerList()
Constructs a empty list of integer values.

Method Detail

add

public int add(int value)
Add a value to the list.

Specified by:
add in interface IntegerCollection
Parameters:
value - Integer value, which should be added.
Returns:
Index of this value.

add

public void add(IntegerCollection collection)
Add a collection of values to this list.

Specified by:
add in interface IntegerCollection
Parameters:
collection - Collection of values.

add

public void add(int[] array)
Add the values of an array to this list.

Specified by:
add in interface IntegerCollection
Parameters:
array - Array of integer values.

remove

public void remove(int index)
Removes a value giving by an index.

Specified by:
remove in interface IntegerCollection
Parameters:
index - Index of the integer value.

set

public void set(int index,
                int value)
Replace a value given by an index.

Specified by:
set in interface IntegerCollection
Parameters:
index - Index of the value, which should be replaced.
value - The new value.

get

public int get(int index)
Return a value from this list given by an index.

Specified by:
get in interface IntegerCollection
Parameters:
index - Index of the value.
Returns:
Integer value.

getCount

public int getCount()
Returns the count of values in this list

Specified by:
getCount in interface IntegerCollection
Returns:
Count of integer values.

indexOf

public int indexOf(int value)
Return the index of a value, otherwise -1.

Specified by:
indexOf in interface IntegerCollection
Parameters:
value - Value, which should found in this list.
Returns:
Index of this value.

contains

public boolean contains(int value)
If the list contains a value.

Specified by:
contains in interface IntegerCollection
Parameters:
value - Value, which should be found in this list.
Returns:
True, if this list contains the value.

removeValue

public void removeValue(int value)
Removes a value from this list.

Specified by:
removeValue in interface IntegerCollection
Parameters:
value - Value to remove.

isEmpty

public boolean isEmpty()
If this list contains no values.

Specified by:
isEmpty in interface IntegerCollection
Returns:
True, if this list is empty.

pop

public int pop()
Pops a value of the end of this list.

Specified by:
pop in interface IntegerCollection
Returns:
Value from the end of this list.

push

public void push(int value)
Pushs a value on top to this list

Specified by:
push in interface IntegerCollection
Parameters:
value - Value, which should be added.

push

public void push(int[] values)
Push values from an array.

Specified by:
push in interface IntegerCollection
Parameters:
values - Array of integer values.

peek

public int peek()
Peek a value of the end of this list.

Specified by:
peek in interface IntegerCollection
Returns:
Integer value.

clear

public void clear()
Removes all values from this list.

Specified by:
clear in interface IntegerCollection

swap

public void swap(int index1,
                 int index2)
Swaps two values from this list.

Specified by:
swap in interface IntegerCollection
Parameters:
index1 - Index from the first value.
index2 - Index from the second value.

toString

public java.lang.String toString()
Return a string representation of the collection.

Specified by:
toString in interface IntegerCollection
Overrides:
toString in class java.lang.Object
Returns:
String representation of the collection.


Copyright ? 2003 Chaperon project. All Rights Reserved.