Ejemplo n.º 1
0
  /**
   * Tells if the hash table contains the superset (or a subset) of a node. This is the same as the
   * function 'containsSupersetOf' just right above, but now we have the option to choose between
   * superset or subset lookup.
   *
   * @param node
   * @param supersetOrSubset
   * @return
   */
  public boolean containsSupersetOrSubsetOf(ITnode node, final int supersetOrSubset) {
    final int index = node.getHash();
    int sizeV, j;

    // increase the size of the hash table dynamically
    if ((sizeV = this.hashTable.size()) < (index + 1)) {
      for (j = 0; j < (index + 1 - sizeV); ++j) {
        this.hashTable.add(null);
      }
      return false;
    }

    Vector<HashElem> pos = this.hashTable.get(index);
    if (pos == null) {
      return false;
    }
    // else
    HashElem elem;
    int supp = node.getSupp();
    BitSet intent = node.getIntent();

    for (Enumeration<HashElem> e = pos.elements(); e.hasMoreElements(); ) {
      elem = e.nextElement();

      if (elem.supp == supp) {
        // looking for a proper superset in the list
        if (supersetOrSubset == MyHash.SUPERSET) {
          if (SetOp.isProperSubset(intent, elem.intent)) {
            return true;
          }
        } else // if (supersetOrSubset == MyHash.SUBSET), i.e. looking for a proper subset in the
               // list
        {
          if (SetOp.isProperSuperset(intent, elem.intent)) {
            return true;
          }
        }
      }
    }

    return false;
  }