Code example for Vector

Methods: clear

0
 */ 
public class MapBinaryHeap<T> 
    extends AbstractCollection<T> 
    implements Queue<T>
{ 
	private Vector<T> heap = new Vector<T>();            // holds the heap as an implicit binary tree
    private Map<T,Integer> object_indices = new HashMap<T,Integer>(); // maps each object in the heap to its index in the heap
    private Comparator<T> comp;
    private final static int TOP = 0;   // the index of the top of the heap
 
    /** 
     * Creates a <code>MapBinaryHeap</code> whose heap ordering 
     * is based on the ordering of the elements specified by <code>c</code>. 
     */ 
    public MapBinaryHeap(Comparator<T> comp)
    { 
        initialize(comp);
    } 
     
    /** 
     * Creates a <code>MapBinaryHeap</code> whose heap ordering 
     * will be based on the <i>natural ordering</i> of the elements, 
     * which must be <code>Comparable</code>. 
     */ 
    public MapBinaryHeap() 
    { 
        initialize(new ComparableComparator()); 
    } 
 
    /** 
     * Creates a <code>MapBinaryHeap</code> based on the specified 
     * collection whose heap ordering 
     * will be based on the <i>natural ordering</i> of the elements, 
     * which must be <code>Comparable</code>. 
     */ 
    public MapBinaryHeap(Collection<T> c)
    { 
    	this(); 
        addAll(c);
    } 
     
    /** 
     * Creates a <code>MapBinaryHeap</code> based on the specified collection  
     * whose heap ordering 
     * is based on the ordering of the elements specified by <code>c</code>. 
     */ 
    public MapBinaryHeap(Collection<T> c, Comparator<T> comp)
    { 
        this(comp);
        addAll(c);
    } 
     
    private void initialize(Comparator<T> comp)
    { 
        this.comp = comp;
        clear(); 
    } 
     
	/** 
	 * @see Collection#clear() 
	 */ 
	@Override 
	public void clear() 
	{ 
        object_indices.clear();
        heap.clear();
	} 
 
	/** 
	 * Inserts <code>o</code> into this collection. 
	 */