Examples of THashSet


Examples of gnu.trove.THashSet

    });
  }

  private void removeFromVariableCaches (Variable victim)
  {
    Set survivors = new THashSet (variablesSet ());
    survivors.remove (victim);

    int vi = 0;
    TIntIntHashMap dict = new TIntIntHashMap (survivors.size ());
    // dict.setDefaultValue (-1);  No longer supported, but this.getIndex() written to avoid need for this.
    my2global = new int[survivors.size ()];

    for (Iterator it = survivors.iterator (); it.hasNext();) {
      Variable var = (Variable) it.next ();
      int gvi = var.getIndex ();
      dict.put (gvi, vi);
      my2global [vi] = gvi;
    }
View Full Code Here

Examples of gnu.trove.THashSet

  /** Returns a collection of all factors that involve only the given variables.
   *   That is, all factors whose domain is a subset of the given collection.
   */
  public Collection allFactorsContaining (Collection vars)
  {
    THashSet factors = new THashSet ();
    for (Iterator it = factorsIterator (); it.hasNext ();) {
      Factor ptl = (Factor) it.next ();
      if (vars.containsAll (ptl.varSet ()))
        factors.add (ptl);
    }
    return factors;
  }
View Full Code Here

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

Examples of gnu.trove.THashSet

/*  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

Examples of gnu.trove.THashSet

/*     */   }
/*     */
/*     */   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

Examples of gnu.trove.THashSet

/*     */       } } ;
/*     */   }
/*     */
/*     */   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

Examples of gnu.trove.THashSet

/*     */       } } ;
/*     */   }
/*     */
/*     */   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

Examples of gnu.trove.THashSet

/*     */   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
Copyright © 2018 www.massapi.com. 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.