fr.inria.opengve.tools.dataStructures
Class BinaryTree<E,V extends java.lang.Comparable<V>>

java.lang.Object
  extended by fr.inria.opengve.tools.dataStructures.BinaryTree<E,V>
Type Parameters:
E - The type of element stored in the tree.
V - The value associated with each element.
All Implemented Interfaces:
PriorityQueue<E,V>

public class BinaryTree<E,V extends java.lang.Comparable<V>>
extends java.lang.Object
implements PriorityQueue<E,V>

Basic implementation of binary tree. You must note that this implementation doesn't balance tree.

Author:
fabrice.peix@sophia.inria.fr

Constructor Summary
BinaryTree()
          Create a new empty tree.
 
Method Summary
 void clear()
          Make the priority queue logically empty.
 boolean contains(E element)
          Say if the priority queue contains a given elemeent.
 E deleteMin()
          Remove the smallest item from the priority queue.
 E find(V k)
          Return object associated with a specific value.
 E findMin()
          Find the smallest item in the priority queue.
 V getValueOf(E element)
          Give the value of a given element.
 void insert(E x, V value)
          Insert into the priority queue.
 boolean isEmpty()
          Test if the priority queue is logically empty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryTree

public BinaryTree()
Create a new empty tree.

Method Detail

clear

public void clear()
Make the priority queue logically empty.

Specified by:
clear in interface PriorityQueue<E,V extends java.lang.Comparable<V>>

deleteMin

public E deleteMin()
            throws java.util.NoSuchElementException
Remove the smallest item from the priority queue.

Specified by:
deleteMin in interface PriorityQueue<E,V extends java.lang.Comparable<V>>
Returns:
the smallest item.
Throws:
java.util.NoSuchElementException - if the priority queue is empty.

findMin

public E findMin()
          throws java.util.NoSuchElementException
Find the smallest item in the priority queue.

Specified by:
findMin in interface PriorityQueue<E,V extends java.lang.Comparable<V>>
Returns:
the smallest item.
Throws:
java.util.NoSuchElementException - if the priority queue is empty.

isEmpty

public boolean isEmpty()
Test if the priority queue is logically empty.

Specified by:
isEmpty in interface PriorityQueue<E,V extends java.lang.Comparable<V>>
Returns:
true if empty, false otherwise.

insert

public void insert(E x,
                   V value)
Insert into the priority queue. Duplicate are allowed.

Specified by:
insert in interface PriorityQueue<E,V extends java.lang.Comparable<V>>
Parameters:
x - The object to insert.
value - The value of the object.

find

public E find(V k)
       throws java.util.NoSuchElementException
Return object associated with a specific value.

Parameters:
k - The value.
Returns:
The object associated with value k.
Throws:
java.util.NoSuchElementException - if the value k is not present in the tree.

contains

public boolean contains(E element)
Say if the priority queue contains a given elemeent.

Specified by:
contains in interface PriorityQueue<E,V extends java.lang.Comparable<V>>
Parameters:
element - The element.
Returns:
true if the element belong to the priority queue and false otherwise.

getValueOf

public V getValueOf(E element)
Give the value of a given element.

Specified by:
getValueOf in interface PriorityQueue<E,V extends java.lang.Comparable<V>>
Parameters:
element - The element.
Returns:
The value of element.


Copyright © 2009 INRIA (Projet Mascotte). All Rights Reserved.