choco.kernel.common.util.objects
Class DoubleLinkedList

java.lang.Object
  extended by choco.kernel.common.util.disposable.Disposable
      extended by choco.kernel.common.util.iterators.DisposableIntIterator
          extended by choco.kernel.common.util.objects.DoubleLinkedList

public class DoubleLinkedList
extends DisposableIntIterator

A double linked list with constant time access, addition and deletion in o(1) The list is encoded by two tables of integers. Efficient implementation regarding time but very poor for memory.


Field Summary
protected  int currentT
          util for iteration
protected  int listSize
          maximum size of the list
protected  int[] nextT
          Successors table
protected  int[] prevT
          Predecessors table
protected  int size
          Current number of elements
 
Constructor Summary
DoubleLinkedList(DoubleLinkedList origin)
          Constructor (copy)
DoubleLinkedList(int listSize)
          build a list of maximum size "listSize"
 
Method Summary
 void addVal(int val)
          Add an element "val"
 boolean contains(int val)
           
 void dispose()
          This method allows to declare that an object is not used anymore.
 int getFirst()
           
 int getLast()
           
 int getSize()
          Get current number of element
 boolean hasNext()
           
 boolean hasNextTo(int val)
           
 boolean isIn(int val)
           
 int next()
          return the next element
 int read()
          return the current iterated element
 void remove()
          remove the current iterated element
 void removeVal(int val)
          Remove an element "val"
 void reset()
          reset
 void restart()
          Initialize the iterator
 void restartFrom(int val)
          Set the iterator from val
 void restrict(int val)
          Restrict the domain to the element val
 int[] toArray()
           
 String toString()
           
 
Methods inherited from class choco.kernel.common.util.disposable.Disposable
init, reusable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nextT

protected final int[] nextT
Successors table


prevT

protected final int[] prevT
Predecessors table


size

protected int size
Current number of elements


currentT

protected int currentT
util for iteration


listSize

protected final int listSize
maximum size of the list

Constructor Detail

DoubleLinkedList

public DoubleLinkedList(int listSize)
build a list of maximum size "listSize"

Parameters:
listSize -

DoubleLinkedList

public DoubleLinkedList(DoubleLinkedList origin)
Constructor (copy)

Method Detail

addVal

public void addVal(int val)
Add an element "val"


removeVal

public void removeVal(int val)
Remove an element "val"


contains

public final boolean contains(int val)

getSize

public final int getSize()
Get current number of element


reset

public void reset()
reset


restart

public final void restart()
Initialize the iterator


restartFrom

public final void restartFrom(int val)
Set the iterator from val

Parameters:
val -

hasNext

public boolean hasNext()

hasNextTo

public boolean hasNextTo(int val)

next

public int next()
return the next element


read

public int read()
return the current iterated element


getFirst

public final int getFirst()

getLast

public final int getLast()

isIn

public final boolean isIn(int val)

restrict

public final void restrict(int val)
Restrict the domain to the element val

Parameters:
val -

toArray

public final int[] toArray()

remove

public void remove()
remove the current iterated element

Overrides:
remove in class DisposableIntIterator

toString

public String toString()
Overrides:
toString in class Object

dispose

public void dispose()
Description copied from class: Disposable
This method allows to declare that an object is not used anymore. It can be reused by another object.

Overrides:
dispose in class Disposable


Copyright © 2012. All Rights Reserved.