コード例 #1
0
ファイル: HashSet.java プロジェクト: sqrlab/VisMAn
 public boolean add(java.lang.Object x) {
   int h = x.hashCode();
   if (h < 0) {
     h = -h;
   }
   h = ~h % buckets.length;
   hashset.HashSet.Node current = buckets[h];
   while (current != null) {
     if (current.data.equals(x)) {
       return false;
     }
     current = current.next;
   }
   hashset.HashSet.Node newNode = new hashset.HashSet.Node();
   newNode.data = x;
   newNode.next = buckets[h];
   buckets[h] = newNode;
   currentSize++;
   return true;
 }