Code example for TreeSet

Methods: iterator

0
            set.remove(set.last());
        } 
    } 
 
    public Iterator<E> iterator() {
        return set.iterator();
    } 
 
    public static void main(String[] args) {
        FixedSizeHeap<Integer> heap = new FixedSizeHeap<Integer>(3);
        heap.add(10);
        heap.add(20);
        heap.add(5);
        heap.add(30);
        Iterator<Integer> iterator = heap.iterator();
        while(iterator.hasNext()) {
            Integer a = iterator.next();
            System.out.println(a);
        } 
    } 
}