eaLib API Docs
Last Modified : January 7 2002

mss.ea.core
Class ListStream

java.lang.Object
  |
  +--mss.ea.core.ListStream
All Implemented Interfaces:
IndividualStream, java.io.Serializable

public class ListStream
extends java.lang.Object
implements IndividualStream

Stream of individuals based on LinkedList.

Since:
0.1
Version:
$Revision: 1.3 $ $Date: 2001/11/22 12:54:10 $
Author:
Andreas Rummler
See Also:
Serialized Form

Field Summary
protected  java.util.LinkedList stream
          Linked list that is encapsulated as a stream.
protected  int streamIndex
          Current position in the stream.
 
Fields inherited from interface mss.ea.core.IndividualStream
serialVersionUID
 
Constructor Summary
ListStream()
          Constructor.
ListStream(java.util.Collection c)
          Constructor with initial collection.
ListStream(Individual[] ia)
          Constructor with initial array.
 
Method Summary
 void add(Individual i)
          Puts an individual to the stream at the current position.
 void add(Individual i, int index)
          Adds an individual to a specific position in the stream.
 void append(Individual i)
          Puts an individual to the end of the stream.
 void empty()
          Removes all individuals from this stream.
 Individual get(int index)
          Gets an individual from a specific position in the stream.
 boolean hasNext()
          Indicates that there is a next individual at the current pointer position.
 boolean hasPrevious()
          Indicates that there is a previous individual at the current pointer position.
 Individual next()
          Gets the next individual from the current position in the stream.
 Individual previous()
          Gets the previous individual from the current position in the stream.
 void reset()
          Sets the internal pointer before the first individual in the stream.
 void resetEnd()
          Sets the internal pointer after the last individual in the stream.
 void resize(int capacity)
          Resizes the stream.
 void set(Individual i, int index)
          Replaces an individual at a specific position with the given individual.
 int size()
          Returns the size of the stream.
 Individual[] toArray()
          Returns the contents of the stream as an array.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

stream

protected java.util.LinkedList stream
Linked list that is encapsulated as a stream.

streamIndex

protected int streamIndex
Current position in the stream.
Constructor Detail

ListStream

public ListStream()
Constructor.

ListStream

public ListStream(java.util.Collection c)
Constructor with initial collection. The user must ensure that the collection holds only objects of type Individual, otherwise there will be a ClassCastException thrwon when accessing the stream.
Parameters:
c - collection of individuals

ListStream

public ListStream(Individual[] ia)
Constructor with initial array.
Parameters:
ia - array of individuals
Method Detail

empty

public void empty()
Description copied from interface: IndividualStream
Removes all individuals from this stream.
Specified by:
empty in interface IndividualStream

add

public void add(Individual i)
Description copied from interface: IndividualStream
Puts an individual to the stream at the current position. The internal pointer is not moved to the next element, so a call to next() returns the element just inserted.
Specified by:
add in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Parameters:
i - individual to add

add

public void add(Individual i,
                int index)
Description copied from interface: IndividualStream
Adds an individual to a specific position in the stream.
Specified by:
add in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Parameters:
i - individual to add
index - position
Throws:
NoSuchElementException - should be thrown in case of an illegal access, but must not be caught

append

public void append(Individual i)
Description copied from interface: IndividualStream
Puts an individual to the end of the stream.
Specified by:
append in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Parameters:
i - individual to append

get

public Individual get(int index)
Description copied from interface: IndividualStream
Gets an individual from a specific position in the stream.
Specified by:
get in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Parameters:
index - position
Returns:
individual at given position
Throws:
NoSuchElementException - should be thrown in case of an illegal access, but must not be caught

set

public void set(Individual i,
                int index)
Description copied from interface: IndividualStream
Replaces an individual at a specific position with the given individual.
Specified by:
set in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Parameters:
i - individual to insert into stream
index - position of replacement
Throws:
NoSuchElementException - should be thrown in case of an illegal access, but must not be caught

next

public Individual next()
Description copied from interface: IndividualStream
Gets the next individual from the current position in the stream.
Specified by:
next in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Returns:
individual from stream

hasNext

public boolean hasNext()
Description copied from interface: IndividualStream
Indicates that there is a next individual at the current pointer position.
Specified by:
hasNext in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Returns:
true, if there is a next individual on the stream

previous

public Individual previous()
Description copied from interface: IndividualStream
Gets the previous individual from the current position in the stream.
Specified by:
previous in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Returns:
individual from stream

hasPrevious

public boolean hasPrevious()
Description copied from interface: IndividualStream
Indicates that there is a previous individual at the current pointer position.
Specified by:
hasPrevious in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Returns:
true, if there is a previous individual on the stream

reset

public void reset()
Description copied from interface: IndividualStream
Sets the internal pointer before the first individual in the stream.
Specified by:
reset in interface IndividualStream

resetEnd

public void resetEnd()
Description copied from interface: IndividualStream
Sets the internal pointer after the last individual in the stream.
Specified by:
resetEnd in interface IndividualStream

resize

public void resize(int capacity)
Description copied from interface: IndividualStream
Resizes the stream.
Specified by:
resize in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Parameters:
size - size of stream

size

public int size()
Description copied from interface: IndividualStream
Returns the size of the stream.
Specified by:
size in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Returns:
size of stream

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toArray

public Individual[] toArray()
Description copied from interface: IndividualStream
Returns the contents of the stream as an array.
Specified by:
toArray in interface IndividualStream
Following copied from interface: mss.ea.core.IndividualStream
Returns:
array with individuals in stream

eaLib API Docs
Last Modified : January 7 2002

Copyright © 2000-2001 Technical University of Ilmenau, Department ESS