Ejemplo n.º 1
0
  /**
   * We have a node, for instance DJ x 1. We are interested if it has a superset registered with the
   * same support (like CDJ x 1). If yes, then return the vector that contains its superset,
   * otherwise return null. We need the vector because the node may have more supersets with the
   * same support!
   *
   * @param node The node whose superset we are looking for in the hash table.
   * @return Container of the superset of the node. If the node has no superset registered, return
   *     null.
   */
  public Vector<HashElem> getSupersetContainerOf(ITnode node) {
    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 null;
    }

    Vector<HashElem> container = this.hashTable.get(index);
    if (container == null) {
      return null;
    }

    // else
    HashElem elem;
    int supp = node.getSupp();
    BitSet intent = node.getIntent();

    for (Enumeration<HashElem> e = container.elements(); e.hasMoreElements(); ) {
      elem = (HashElem) e.nextElement();
      if (elem.supp == supp) {
        if (SetOp.isProperSubset(intent, elem.intent)) {
          return container;
        }
      }
    }
    return null;
  }
Ejemplo n.º 2
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;
  }
Ejemplo n.º 3
0
  /**
   * We have a registered elem in the hash. We thought that it was a frequent generator but we
   * eventually found a subset of it with the same support. !!! More subsets may be registered !!!
   * Thus we delete ALL these supersets and we register the subset.
   *
   * @param elemContainer The vector that contains the supersets.
   * @param node The subset that we want to store instead.
   * @return How the number of elements changed (it can be 0 or negative).
   */
  public int replace(Vector<HashElem> elemContainer, ITnode node) {
    Vector<HashElem> container = this.hashTable.get(node.getHash());
    HashElem elem;
    int supp = node.getSupp();
    BitSet intent = node.getIntent();
    Vector<HashElem> toDelete = new Vector<HashElem>();

    for (Enumeration<HashElem> e = container.elements(); e.hasMoreElements(); ) {
      elem = e.nextElement();
      if (elem.supp == supp) {
        if (SetOp.isProperSubset(intent, elem.intent)) {
          toDelete.add(elem);
        }
      }
    }

    container.removeAll(toDelete);
    this.add(node);

    return (0 - toDelete.size() + 1);
  }