LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.misc
Class LyMultiList<T>

java.lang.Object
  extended by leon.misc.LyMultiList<T>

public final class LyMultiList<T>
extends java.lang.Object

This class is an utility class to manage a list of objects with a counter of occurences for each object. It is like a java Hashtable containing these objects as keys and an integer value as values.

See Also:
Hashtable, Vector

Field Summary
static java.lang.String __VERSION
           
 
Constructor Summary
LyMultiList()
          Default constructor.
 
Method Summary
 int addObject(T object)
          Adds the given object to the objects list.
 void clearObject(T object)
          Removes all occurences of an object in this list.
 boolean contains(T object)
          Checks if the given object is contained in this list.
 int getCount(T object)
          Gets the number of occurences of the given object.
 int getIndex(T object)
          Gets the index of the given object.
 T getObject(int index)
          Gets the object at the specified index.
 java.util.Vector<T> getObjects()
          Gets the set of objects.
 int getSize()
          Gets the number of objects in this list.
 int removeObject(T object)
          Removes an occurence of the specified object from this list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values
Constructor Detail

LyMultiList

public LyMultiList()
Default constructor. Sets the list of objects to null.

Method Detail

contains

public boolean contains(T object)
Checks if the given object is contained in this list.

Parameters:
object - The object to find.
Returns:
true if the given object is found, false otherwise.

getIndex

public int getIndex(T object)
Gets the index of the given object.

Parameters:
object - The object.
Returns:
The index if the object if it is found in this list, -1 otherwise.

getCount

public int getCount(T object)
Gets the number of occurences of the given object.

Parameters:
object - The object.
Returns:
The number of occurences of the object if found in this list, 0 otherwise.

getSize

public int getSize()
Gets the number of objects in this list.

Returns:
the number of objects in this list or -1 if no object was added yet.

getObject

public T getObject(int index)
Gets the object at the specified index.

Parameters:
index - The index of the requested object.
Returns:
The reference to the requested object, or null if it could not be found.

addObject

public int addObject(T object)
Adds the given object to the objects list.
If the object is ever in the list, increment its number of occurence
Else builds adds the object to the list.

Parameters:
object - the object to add
Returns:
The number of occurences of the object.

removeObject

public int removeObject(T object)
Removes an occurence of the specified object from this list.
If the object occurence number equals 1, the object is removed from the list,
Else, the number of occurences is decremented.

Parameters:
object - Object to remove.
Returns:
The number of remaining occurences of the object or -1 if the object was not in the list.

clearObject

public void clearObject(T object)
Removes all occurences of an object in this list.

Parameters:
object - The object to remove from the list.

getObjects

public java.util.Vector<T> getObjects()
Gets the set of objects. This is a COPY of the internal list, therefore this list may be freely manipulated by the application.

Returns:
The set of objects if any, an empty Vector if the set is empty.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com