net.sourceforge.chaperon.common
Class IntegerSet

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

public class IntegerSet
extends java.lang.Object
implements IntegerCollection

This class represents a set of integer values, which means there doesn't exist multiple instances of values.

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

Constructor Summary
IntegerSet()
          Creates an empty set of integer values.
 
Method Summary
 int add(int value)
          Add a value to this set.
 void add(int[] array)
          Add the values of an array to this set.
 void add(IntegerCollection collection)
          Add the values of an other integer collection to this set.
 void clear()
          Removes all values from this set
 boolean contains(int value)
          If the list contains a value.
 int get(int index)
          Return a value from this set given by an index.
 int getCount()
          Returns the count of value in this set.
 int indexOf(int value)
          Return the index of a value, otherwise -1
 boolean isEmpty()
          If this set contains no values.
 int peek()
          Peek a value of the end of this set.
 int pop()
          Pops a value of the end of this set.
 void push(int value)
          Pushs a value 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 set.
 void set(int index, int value)
          Replace a value given by an index.
 void swap(int index1, int index2)
          Swaps two values from this set.
 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

IntegerSet

public IntegerSet()
Creates an empty set of integer values.

Method Detail

add

public int add(int value)
Add a value to this set.

Specified by:
add in interface IntegerCollection
Parameters:
value - Integer value.
Returns:
Index of this value.

add

public void add(IntegerCollection collection)
Add the values of an other integer collection to this set.

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 set.

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 set 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 value in this set.

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 be found in this set.
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 set
Returns:
True, if this set contains the value.

removeValue

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

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

isEmpty

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

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

pop

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

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

push

public void push(int value)
Pushs a value 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 set.

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

clear

public void clear()
Removes all values from this set

Specified by:
clear in interface IntegerCollection

swap

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

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.