Package gnu.trove

Examples of gnu.trove.THashSet


    return szs;
  }

  public static VarSet defaultIntersection (VarSet v1, VarSet v2)
  {// Grossly inefficient implementation
    THashSet hset = new THashSet (v1);
    hset.retainAll (v2);
    Variable[] ret = new Variable [hset.size ()];

    int vai = 0;
    for (int vi = 0; vi < v1.size(); vi++) {
      Variable var = v1.get (vi);
      if (hset.contains (var)) { ret[vai++] = var; }
    }

    return new HashVarSet (ret);
  }
View Full Code Here


/*  48 */           s.add(i.next());
/*     */       }
/*     */
/*     */       public void ours()
/*     */       {
/*  53 */         Set s = new THashSet(100000);
/*  54 */         for (Iterator i = Main.dataset.iterator(); i.hasNext(); )
/*  55 */           s.add(i.next());
/*     */       }
/*     */
/*     */       public String toString()
/*     */       {
/*  60 */         return "compares " + Main.dataset.size() + " Set.add() operations";
View Full Code Here

/*     */   }
/*     */
/*     */   static Operation getContainsOp() {
/* 104 */     Set theirs = new HashSet(dataset.size());
/* 105 */     theirs.addAll(dataset);
/* 106 */     Set ours = new THashSet(dataset.size());
/* 107 */     ours.addAll(dataset);
/*     */
/* 109 */     return new Operation(theirs, ours) { private final Set val$theirs;
/*     */       private final Set val$ours;
/*     */
/* 111 */       public void theirs() { for (int i = 0; i < Main.dataset.size(); i += 5)
View Full Code Here

/*     */       } } ;
/*     */   }
/*     */
/*     */   static Operation getRandomSetContainsOp() {
/* 133 */     Set theirs = new HashSet(100000);
/* 134 */     Set ours = new THashSet(100000);
/* 135 */     Random rand = new Random(9999L);
/*     */
/* 137 */     for (int i = 0; i < 100000; i++) {
/* 138 */       Integer x = new Integer(rand.nextInt());
/* 139 */       theirs.add(x);
/* 140 */       ours.add(x);
/*     */     }
/*     */
/* 143 */     Random rand2 = new Random(9998L);
/* 144 */     List query = new ArrayList(100000);
/* 145 */     int match = 0;
View Full Code Here

/*     */       } } ;
/*     */   }
/*     */
/*     */   static Operation getSumSetOperation() {
/* 303 */     Set theirSet = new HashSet(dataset.size());
/* 304 */     THashSet ourSet = new THashSet(dataset.size());
/* 305 */     theirSet.addAll(dataset);
/* 306 */     ourSet.addAll(dataset);
/* 307 */     TObjectProcedure proc = new TObjectProcedure() {
/* 308 */       int sum = 0;
/*     */
/* 310 */       public boolean execute(Object o) { this.sum += ((Integer)o).intValue();
/* 311 */         return true;
View Full Code Here

/*     */   static class TroveSetCreator
/*     */     implements MemoryUsage.Creator
/*     */   {
/*     */     public Object create()
/*     */     {
/* 178 */       THashSet map = new THashSet();
/* 179 */       for (int i = 0; i < 1000; i++) {
/* 180 */         Integer x = new Integer(i);
/* 181 */         map.add(x);
/*     */       }
/* 183 */       return map;
/*     */     }
View Full Code Here

TOP

Related Classes of gnu.trove.THashSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.