KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > DxLib > DxTreeSet


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: DxTreeSet.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
8

9 package org.ozoneDB.DxLib;
10
11
12 /**
13  *
14  *
15  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
16  * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
17  */

18 public class DxTreeSet extends DxAbstractSet implements DxTreeCollection {
19     //, Externalizable {
20

21     final static long serialVersionUID = 1L;
22     
23     protected transient DxBBTree bbtree;
24     
25     protected DxComparator comparator;
26     
27     
28     /**
29      * Constructs a new, empty set. All keys inserted into the map must
30      * implement the DxComparable interface.
31      */

32     public DxTreeSet() {
33         comparator = new DxStandardComparator();
34         bbtree = new DxBBTree( comparator );
35     }
36     
37     
38     /**
39      * Constructs a new, empty set, sorted according to the given comparator.
40      * All inserted objects must be comparable by the given comparator.
41      */

42     public DxTreeSet( DxComparator _comparator ) {
43         comparator = _comparator;
44         bbtree = new DxBBTree( comparator );
45     }
46     
47     
48     public Object JavaDoc clone() {
49         DxSet newSet = new DxTreeSet( comparator );
50         return clone( newSet );
51     }
52     
53     
54     public synchronized boolean add( Object JavaDoc obj ) {
55         return bbtree.addForKey( obj, obj );
56     }
57     
58     
59     public synchronized boolean remove( Object JavaDoc obj ) {
60         return bbtree.removeForKey( obj ) != null;
61     }
62     
63     
64     public boolean contains( Object JavaDoc obj ) {
65         return bbtree.containsKey( obj );
66     }
67     
68     
69     public DxIterator iterator() {
70         return new DxBBIterator( this );
71     }
72     
73     
74     public int count() {
75         return bbtree.count();
76     }
77     
78     
79     public boolean isEmpty() {
80         return bbtree.isEmpty();
81     }
82     
83     
84     public synchronized void clear() {
85         bbtree = new DxBBTree();
86     }
87     
88     
89     public DxBBTree internalTree() {
90         return bbtree;
91     }
92     
93     
94     // public void writeExternal (ObjectOutput out) throws IOException {
95
// // System.out.println (getClass().getName() + ".writeExternal()...");
96
// out.writeObject (comparator);
97
// super.writeExternal (out);
98
// }
99
//
100
//
101
// public synchronized void readExternal (ObjectInput in) throws IOException, ClassNotFoundException {
102
// comparator = (DxComparator)in.readObject();
103
// bbtree = new DxBBTree (comparator);
104
// super.readExternal (in);
105
// }
106

107 }
108
Popular Tags