Examples of Trie


Examples of weka.core.Trie

  // init packages
  m_Packages = new Vector<String>();
  m_Packages.addAll(set);
  Collections.sort(m_Packages);
 
  m_Trie = new Trie();
  m_Trie.addAll(m_Packages);
      }
    }
View Full Code Here

Examples of weka.core.Trie

      String    cls;
      Vector<String>   result;
      Vector<String>   list;
      int    i;
      int    index;
      Trie    tmpTrie;
      HashSet    set;
      String    tmpStr;
     
      pkg = getPackage(partial);
      cls = getClassname(partial);
     
      if (getDebug())
  System.out.println(
      "\nsearch for: '" + partial + "' => package=" + pkg + ", class=" + cls);

      result = new Vector<String>();

      // find all packages that start with that string
      if (cls.length() == 0) {
  list = m_Trie.getWithPrefix(pkg);
  set  = new HashSet();
  for (i = 0; i < list.size(); i++) {
    tmpStr = list.get(i);
    if (tmpStr.length() < partial.length())
      continue;
    if (tmpStr.equals(partial))
      continue;
   
    index  = tmpStr.indexOf('.', partial.length() + 1);
    if (index > -1)
      set.add(tmpStr.substring(0, index));
    else
      set.add(tmpStr);
  }

  result.addAll(set);
  if (result.size() > 1)
    Collections.sort(result);
      }

      // find all classes that start with that string
      list = ClassDiscovery.find(Object.class, pkg);
      tmpTrie = new Trie();
      tmpTrie.addAll(list);
      list = tmpTrie.getWithPrefix(partial);
      result.addAll(list);
     
      // sort the result
      if (result.size() > 1)
  Collections.sort(result);
View Full Code Here

Examples of weka.core.Trie

     * @param list  the list to return the common prefix for
     * @return    the common prefix of all the items
     */
    public String getCommonPrefix(Vector<String> list) {
      String  result;
      Trie  trie;
     
      trie = new Trie();
      trie.addAll(list);
      result = trie.getCommonPrefix();
     
      if (m_Debug)
  System.out.println(list + "\n  --> common prefix: '" + result + "'");
     
      return result;
View Full Code Here

Examples of wyfs.util.Trie

    return wf;
  }

  private Trie parsePackage() {
    Trie pkg = Trie.ROOT;

    if (tryAndMatch(true, Package) != null) {
      // found a package keyword
      pkg = pkg.append(match(Identifier).text);

      while (tryAndMatch(true, Dot) != null) {
        pkg = pkg.append(match(Identifier).text);
      }

      matchEndLine();
      return pkg;
    } else {
View Full Code Here

Examples of wyfs.util.Trie

      }
      token = match(Identifier);
    }

    // Second, parse package string
    Trie filter = Trie.ROOT.append(token.text);
    token = null;
    while ((token = tryAndMatch(true, Dot, DotDot)) != null) {
      if (token.kind == DotDot) {
        filter = filter.append("**");
      }
      if (tryAndMatch(true, Star) != null) {
        filter = filter.append("*");
      } else {
        filter = filter.append(match(Identifier).text);
      }
    }

    int end = index;
    matchEndLine();
View Full Code Here

Examples of wyfs.util.Trie

    HashSet<Pair<NameID, Nominal.FunctionOrMethod>> candidates = new HashSet<Pair<NameID, Nominal.FunctionOrMethod>>();
    // first, try to find the matching message
    for (WhileyFile.Import imp : context.imports()) {
      String impName = imp.name;
      if (impName == null || impName.equals(name) || impName.equals("*")) {
        Trie filter = imp.filter;
        if (impName == null) {
          // import name is null, but it's possible that a module of
          // the given name exists, in which case any matching names
          // are automatically imported.
          filter = filter.parent().append(name);
        }
        for (Path.ID mid : builder.imports(filter)) {
          NameID nid = new NameID(mid, name);
          addCandidateFunctionsAndMethods(nid, parameters,
              candidates, context);
View Full Code Here

Examples of wyfs.util.Trie

  public NameID resolveAsName(String name, Context context)
      throws IOException, ResolveError {
    for (WhileyFile.Import imp : context.imports()) {
      String impName = imp.name;
      if (impName == null || impName.equals(name) || impName.equals("*")) {
        Trie filter = imp.filter;
        if (impName == null) {
          // import name is null, but it's possible that a module of
          // the given name exists, in which case any matching names
          // are automatically imported.
          filter = filter.parent().append(name);
        }
        for (Path.ID mid : builder.imports(filter)) {
          NameID nid = new NameID(mid, name);
          if (builder.isName(nid)) {
            // ok, we have found the name in question. But, is it
View Full Code Here

Examples of wyfs.util.Trie

   */
  public Path.ID resolveAsModule(String name, Context context)
      throws IOException, ResolveError {

    for (WhileyFile.Import imp : context.imports()) {
      Trie filter = imp.filter;
      String last = filter.last();
      if (last.equals("*")) {
        // this is generic import, so narrow the filter.
        filter = filter.parent().append(name);
      } else if (!last.equals(name)) {
        continue; // skip as not relevant
      }

      for (Path.ID mid : builder.imports(filter)) {
View Full Code Here

Examples of wyfs.util.Trie

    return wf;
  }

  private Trie parsePackage() {
    Trie pkg = Trie.ROOT;

    if (tryAndMatch(true, Package) != null) {
      // found a package keyword
      pkg = pkg.append(match(Identifier).text);

      while (tryAndMatch(true, Dot) != null) {
        pkg = pkg.append(match(Identifier).text);
      }

      matchEndLine();
      return pkg;
    } else {
View Full Code Here

Examples of wyfs.util.Trie

      }
      token = match(Identifier);
    }

    // Second, parse package string
    Trie filter = Trie.ROOT.append(token.text);
    token = null;
    while ((token = tryAndMatch(true, Dot, DotDot)) != null) {
      if (token.kind == DotDot) {
        filter = filter.append("**");
      }
      if (tryAndMatch(true, Star) != null) {
        filter = filter.append("*");
      } else {
        filter = filter.append(match(Identifier).text);
      }
    }

    int end = index;
    matchEndLine();
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.