Examples of IntSet


Examples of it.unimi.dsi.fastutil.ints.IntSet

    for (int i=0;i<docs.length;++i)
    {
      docs[i]=i;
    }
    int limit = 10000;
    IntSet set1 = new IntRBTreeSet();
    while(set1.size() < limit)
    {
      set1.add(rand.nextInt(max));
    }
   
    IntSet set2 = new IntOpenHashSet();
    for (int i : set1)
    {
      set2.add(i);
    }
   
    int[] set3 = set1.toIntArray();
    Arrays.sort(set3);
   
    BitSet set4 = new BitSet();
    for (int i : set1)
    {
      set4.set(i);
    }
   
    long start,end;
   
    start=System.nanoTime();
    for (int i=0;i<docs.length;++i)
    {
      set1.contains(i);
    }
    end=System.nanoTime();
    System.out.println("set1: "+(end-start)/1000000);
   
    start=System.nanoTime();
    for (int i=0;i<docs.length;++i)
    {
      set2.contains(i);
    }
    end=System.nanoTime();
    System.out.println("set2: "+(end-start)/1000000);
   
    start=System.nanoTime();
View Full Code Here

Examples of kodkod.util.ints.IntSet

      final Translation translation = Translator.translate(formula, bounds, options);
      final long endTransl = System.currentTimeMillis();

      final SATMinSolver cnf = (SATMinSolver)translation.cnf();
      for(Relation r : bounds.relations()) {
        IntSet vars = translation.primaryVariables(r);
        if (vars != null) {
          int rcost = cost.edgeCost(r);
          for(IntIterator iter = vars.iterator();  iter.hasNext(); ) {
            cnf.setCost(iter.next(), rcost);
          }
        }
      }
     
View Full Code Here

Examples of net.sf.saxon.sort.IntSet

    protected void fixupInsertedNamespaces(boolean inherit) {
        if (parent.getNodeKind() == Type.DOCUMENT) {
            return;
        }

        IntSet childNamespaces = new IntHashSet();
        if (namespaceList != null) {
            for (int i=0; i<namespaceList.length; i++) {
                childNamespaces.add(namespaceList[i]);
            }
        }

        NamespaceResolver inscope = new InscopeNamespaceResolver(parent);
        NamePool pool = getNamePool();

        // If the child is in the null namespace but the parent has a default namespace, xmlns="" should be added.

        if (getURI().length()==0 && inscope.getURIForPrefix("", true).length()!=0) {
            childNamespaces.add(0);
        }

        // Namespaces present on the parent but not on the child should be undeclared (if requested)

        if (!inherit) {
            Iterator it = inscope.iteratePrefixes();
            while (it.hasNext()) {
                String prefix = (String)it.next();
                int prefixCode = pool.getCodeForPrefix(prefix)<<16;
                boolean found = false;
                if (namespaceList != null) {
                    for (int i=0; i<namespaceList.length; i++) {
                        if ((namespaceList[i] & 0xffff) == prefixCode) {
                            found = true;
                            break;
                        }
                    }
                }
                if (!found) {
                    childNamespaces.add(prefixCode);
                }
            }
        }

        // Redundant namespaces should be removed

        if (namespaceList != null) {
            for (int i=0; i<namespaceList.length; i++) {
                int nscode = namespaceList[i];
                String prefix = pool.getPrefixFromNamespaceCode(nscode);
                String uri = pool.getURIFromNamespaceCode(nscode);
                String parentUri = inscope.getURIForPrefix(prefix, true);
                if (parentUri != null && parentUri.equals(uri)) {
                    // the namespace declaration is redundant
                    childNamespaces.remove(nscode);
                }
            }
        }
        int[] n2 = new int[childNamespaces.size()];
        int j = 0;
        IntIterator ii = childNamespaces.iterator();
        while (ii.hasNext()) {
            n2[j++] = ii.next();
        }
        namespaceList = n2;
    }
View Full Code Here

Examples of org.antlr.misc.IntSet

        "reachableLabels="+reachableLabels.toString());
        */
    if ( reachableLabels.contains(label) ) { // exact label present
            return;
        }
        IntSet t = label.getSet();
        IntSet remainder = t; // remainder starts out as whole set to add
        int n = reachableLabels.size(); // only look at initial elements
        // walk the existing list looking for the collision
        for (int i=0; i<n; i++) {
      Label rl = reachableLabels.get(i);
            /*
      System.out.println("comparing ["+i+"]: "+label.toString(dfa.nfa.grammar)+" & "+
                    rl.toString(dfa.nfa.grammar)+"="+
                    intersection.toString(dfa.nfa.grammar));
            */
      if ( !Label.intersect(label, rl) ) {
                continue;
            }
      //System.out.println(label+" collides with "+rl);

      // For any (s_i, t) with s_i&t!=nil replace with (s_i-t, s_i&t)
            // (ignoring s_i-t if nil; don't put in list)

            // Replace existing s_i with intersection since we
            // know that will always be a non nil character class
      IntSet s_i = rl.getSet();
      IntSet intersection = s_i.and(t);
            reachableLabels.set(i, new Label(intersection));

            // Compute s_i-t to see what is in current set and not in incoming
            IntSet existingMinusNewElements = s_i.subtract(t);
      //System.out.println(s_i+"-"+t+"="+existingMinusNewElements);
            if ( !existingMinusNewElements.isNil() ) {
                // found a new character class, add to the end (doesn't affect
                // outer loop duration due to n computation a priori.
                Label newLabel = new Label(existingMinusNewElements);
                reachableLabels.add(newLabel);
            }
View Full Code Here

Examples of org.antlr.misc.IntSet

    if ( transition0.label.isAtom() ) {
      int atom = transition0.label.getAtom();
      return new LookaheadSet(atom);
    }
    if ( transition0.label.isSet() ) {
      IntSet sl = transition0.label.getSet();
      return new LookaheadSet(sl);
    }

    // compute FIRST of transition 0
    LookaheadSet tset = null;
View Full Code Here

Examples of org.antlr.misc.IntSet

  public boolean member(int a) {
    return tokenTypeSet.member(a);
  }

  public LookaheadSet intersection(LookaheadSet s) {
    IntSet i = this.tokenTypeSet.and(s.tokenTypeSet);
    LookaheadSet intersection = new LookaheadSet(i);
    return intersection;
  }
View Full Code Here

Examples of org.antlr.misc.IntSet

      List<Set<NFAState>> nfaStates, List<IntSet> labels) {
    List<Token> tokens = new ArrayList<Token>();
    for (int i = 0; i < nfaStates.size() - 1; i++) {
      Set<NFAState> cur = nfaStates.get(i);
      Set<NFAState> next = nfaStates.get(i + 1);
      IntSet label = labels.get(i);
      // find NFA state with edge whose label matches labels[i]
      nfaConfigLoop:
     
      for (NFAState p : cur) {
        // walk p's transitions, looking for label
View Full Code Here

Examples of org.antlr.misc.IntSet

   */
  public IntSet getAllCharValues() {
    if ( charVocabulary!=null ) {
      return charVocabulary;
    }
    IntSet allChar = IntervalSet.of(Label.MIN_CHAR_VALUE, getMaxCharValue());
    return allChar;
  }
View Full Code Here

Examples of org.antlr.misc.IntSet

   *  from MIN_TOKEN_TYPE to last valid token type or char value.
   */
  public IntSet complement(IntSet set) {
    //System.out.println("complement "+set.toString(this));
    //System.out.println("vocabulary "+getTokenTypes().toString(this));
    IntSet c = set.complement(getTokenTypes());
    //System.out.println("result="+c.toString(this));
    return c;
  }
View Full Code Here

Examples of org.antlr.misc.IntSet

  {
    Rule r = getRule(ruleName);
    if ( r==null ) {
      return null;
    }
    IntSet elements;
    //System.out.println("parsed tree: "+r.tree.toStringTree());
    elements = nfabuilder.setRule(r.tree);
    //System.out.println("elements="+elements);
    return elements;
  }
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.