Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## nl.tudelft.simulation.dsol.eventlists
Class RedBlackTree

    java.lang.Object
      nl.tudelft.simulation.dsol.eventlists.RedBlackTree

All Implemented Interfaces:
  EventListInterface, java.io.Serializable

Direct Known Subclasses:
  TableModelEventList

public class RedBlackTree
extends java.lang.Object
implements EventListInterface

A RedBlackTree implementation of the eventlistInterface. This implementation is based on Java's TreeSet.

(c) copyright 2003 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl
License of use: General Public License (GPL) , no warranty

Since:
  1.0
Version:
  1.4 2004-03-28
Author:
  Peter Jacobs
See Also:
  Serialized Form

Field Summary
`protected static boolean` | `BLACK` BLACK
`protected int` | `modCount` The number of structural modifications to the tree.
`protected static boolean` | `RED` RED
`protected nl.tudelft.simulation.dsol.eventlists.RedBlackTree.Entry` | `root` the root of the tree
`protected int` | `size` The number of entries in the tree

Constructor Summary
`RedBlackTree()` constructs a new RedBlackTree

Method Summary
`boolean` | `add(SimEventInterface event)` adds an event to the eventlist
`boolean` | `addAll(java.util.Collection collection)` adds a collection of events to the tree
`void` | `clear()` clears the eventlist by removing all its scheduled events.
`boolean` | `contains(SimEventInterface event)` returns whether event is an entry of the eventlist
`boolean` | `containsAll(java.util.Collection collection)` returns whether the collection is in the list.
`protected void` | `deleteEntry(nl.tudelft.simulation.dsol.eventlists.RedBlackTree.Entry entry)` deletes entry , and then rebalance the tree.
`SimEventInterface` | `first()` returns the first scheduled event
`protected nl.tudelft.simulation.dsol.eventlists.RedBlackTree.Entry` | `firstEntry()` returns the first entry from the RedBlackTree
`boolean` | `isEmpty()` returns whether the eventlist is empty
`java.util.Iterator` | `iterator()` returns the iterator for this eventlist
`SimEventInterface` | `last()` returns the last scheduled event
`boolean` | `remove(SimEventInterface event)` removes the event from this tree
`boolean` | `removeAll(java.util.Collection collection)` removes a collection of events from this tree
`SimEventInterface` | `removeFirst()` removes the first event from the eventlist.
`SimEventInterface` | `removeLast()` removes the last event from the eventlist.
`int` | `size()` returns the number of scheduled events
`protected nl.tudelft.simulation.dsol.eventlists.RedBlackTree.Entry` | `successor(nl.tudelft.simulation.dsol.eventlists.RedBlackTree.Entry entry)` Returns the successor of the specified Entry, or null if no such.
`SimEventInterface[]` | `toArray()` returns the eventlist as array of simevents

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### RED

    protected static final boolean RED

  RED

  See Also:
    Constant Field Values

### BLACK

    protected static final boolean BLACK

  BLACK

  See Also:
    Constant Field Values

### root

    protected transient nl.tudelft.simulation.dsol.eventlists.RedBlackTree.Entry root

  the root of the tree

### size

    protected transient int size

  The number of entries in the tree

### modCount

    protected transient int modCount

  The number of structural modifications to the tree.

Constructor Detail

### RedBlackTree

    public RedBlackTree()

  constructs a new RedBlackTree

Method Detail

### add

    public boolean add(SimEventInterface event)

  Description copied from interface: `EventListInterface`
  adds an event to the eventlist

  Specified by:
    `add` in interface `EventListInterface`
  Parameters:
    `event` - the event to add
  Returns:
    true whenever the event was not already scheduled.
  See Also:
    `#add(nl.tudelft.simulation.dsol.formalisms.devs.SimEventInterface)`

### addAll

    public boolean addAll(java.util.Collection collection)

  Description copied from interface: `EventListInterface`
  adds a collection of events to the tree

  Specified by:
    `addAll` in interface `EventListInterface`
  Parameters:
    `collection` - the collection
  Returns:
    true whenever the collection was sucessfully added.
  See Also:
    `#addAll(Collection)`

### clear

    public void clear()

  Description copied from interface: `EventListInterface`
  clears the eventlist by removing all its scheduled events.

  Specified by:
    `clear` in interface `EventListInterface`
  See Also:
    `EventListInterface.clear()`

### contains

    public boolean contains(SimEventInterface event)

  Description copied from interface: `EventListInterface`
  returns whether event is an entry of the eventlist

  Specified by:
    `contains` in interface `EventListInterface`
  Parameters:
    `event` - the event
  Returns:
    true if event in tree; otherwise false.
  See Also:
    `#contains(nl.tudelft.simulation.dsol.formalisms.devs.SimEventInterface)`

### containsAll

    public boolean containsAll(java.util.Collection collection)

  Description copied from interface: `EventListInterface`
  returns whether the collection is in the list.

  Specified by:
    `containsAll` in interface `EventListInterface`
  Parameters:
    `collection` - the collection to test
  Returns:
    true if event in tree; otherwise false.
  See Also:
    `#containsAll(Collection)`

### first

    public SimEventInterface first()

  Description copied from interface: `EventListInterface`
  returns the first scheduled event

  Specified by:
    `first` in interface `EventListInterface`
  Returns:
    first scheduled event.
  See Also:
    `#first()`

### isEmpty

    public boolean isEmpty()

  Description copied from interface: `EventListInterface`
  returns whether the eventlist is empty

  Specified by:
    `isEmpty` in interface `EventListInterface`
  Returns:
    true if empty.
  See Also:
    `EventListInterface.isEmpty()`

### iterator

    public java.util.Iterator iterator()

  Description copied from interface: `EventListInterface`
  returns the iterator for this eventlist

  Specified by:
    `iterator` in interface `EventListInterface`
  Returns:
    the iterator
  See Also:
    `#iterator()`

### last

    public SimEventInterface last()

  Description copied from interface: `EventListInterface`
  returns the last scheduled event

  Specified by:
    `last` in interface `EventListInterface`
  Returns:
    last scheduled event.
  See Also:
    `EventListInterface.last()`

### remove

    public boolean remove(SimEventInterface event)

  Description copied from interface: `EventListInterface`
  removes the event from this tree

  Specified by:
    `remove` in interface `EventListInterface`
  Parameters:
    `event` - the event to be removed
  Returns:
    true if the event was in the tree and succesfully removed.
  See Also:
    `#remove(nl.tudelft.simulation.dsol.formalisms.devs.SimEventInterface)`

### removeAll

    public boolean removeAll(java.util.Collection collection)

  Description copied from interface: `EventListInterface`
  removes a collection of events from this tree

  Specified by:
    `removeAll` in interface `EventListInterface`
  Parameters:
    `collection` - the colleciton
  Returns:
    true if the event was in the tree and succesfully removed.
  See Also:
    `EventListInterface.removeAll(Collection)`

### removeFirst

    public SimEventInterface removeFirst()

  Description copied from interface: `EventListInterface`
  removes the first event from the eventlist.

  Specified by:
    `removeFirst` in interface `EventListInterface`
  Returns:
    the first event
  See Also:
    `#removeFirst()`

### removeLast

    public SimEventInterface removeLast()

  Description copied from interface: `EventListInterface`
  removes the last event from the eventlist.

  Specified by:
    `removeLast` in interface `EventListInterface`
  Returns:
    the last event
  See Also:
    `EventListInterface.removeLast()`

### size

    public int size()

  Description copied from interface: `EventListInterface`
  returns the number of scheduled events

  Specified by:
    `size` in interface `EventListInterface`
  Returns:
    the number of scheduled events.
  See Also:
    `EventListInterface.size()`

### toArray

    public SimEventInterface[] toArray()

  Description copied from interface: `EventListInterface`
  returns the eventlist as array of simevents

  Specified by:
    `toArray` in interface `EventListInterface`
  Returns:
    the eventlist as array of simevents.
  See Also:
    `#toArray()`

### firstEntry

    protected nl.tudelft.simulation.dsol.eventlists.RedBlackTree.Entry firstEntry()

  returns the first entry from the RedBlackTree

  Returns:
    the first Entry

### deleteEntry

    protected void deleteEntry(nl.tudelft.simulation.dsol.eventlists.RedBlackTree.Entry entry)

  deletes entry , and then rebalance the tree.

  Parameters:
    `entry` - entry

### successor

    protected nl.tudelft.simulation.dsol.eventlists.RedBlackTree.Entry successor(nl.tudelft.simulation.dsol.eventlists.RedBlackTree.Entry entry)

  Returns the successor of the specified Entry, or null if no such.

  Parameters:
    `entry` - the entry
  Returns:
    Entry the successor

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2004 Delft University of Technology, the Netherlands. All Rights Reserved.