Ejemplo n.º 1
0
  public void removeUndefeated(
      DefeasibleLogicalDependency dep, LinkedListEntry<DefeasibleLogicalDependency> node) {
    boolean pos = dep.getValue() == null || MODE.POSITIVE.getId().equals(dep.getValue().toString());
    switch (dep.getStatus()) {
      case DEFINITELY:
        if (pos) {
          definitelyPosCount--;
          if (definitelyPosCount == 0) {
            statusMask = statusMask ^ DEFINITELY_POS_BIT;
          }
        } else {
          definitelyNegCount--;
          if (definitelyNegCount == 0) {
            statusMask = statusMask ^ DEFINITELY_NEG_BIT;
          }
        }
        break;
      case DEFEASIBLY:
        if (pos) {
          defeasiblyPosCount--;
          if (defeasiblyPosCount == 0) {
            statusMask = statusMask ^ DEFEASIBLY_POS_BIT;
          }
        } else {
          defeasiblyNegCount--;
          if (defeasiblyNegCount == 0) {
            statusMask = statusMask ^ DEFEASIBLY_NEG_BIT;
          }
        }
        break;
      case DEFEATEDLY:
        if (pos) {
          defeatedlyPosCount--;
          if (defeatedlyPosCount == 0) {
            statusMask = statusMask ^ DEFEATEDLY_POS_BIT;
          }
        } else {
          defeatedlyNegCount--;
          if (defeatedlyNegCount == 0) {
            statusMask = statusMask ^ DEFEATEDLY_NEG_BIT;
          }
        }
        break;
      case UNDECIDABLY:
        throw new IllegalStateException("Individual logical dependencies cannot be undecidably");
    }

    if (this.rootUndefeated == node) {
      removeFirst();
    } else if (this.tailUndefeated == node) {
      removeLast();
    } else {
      node.getPrevious().setNext(node.getNext());
      ((LinkedListNode) node.getNext()).setPrevious(node.getPrevious());
      node.nullPrevNext();
    }
  }
Ejemplo n.º 2
0
  public void addUndefeated(
      DefeasibleLogicalDependency dep, LinkedListEntry<DefeasibleLogicalDependency> node) {
    boolean pos = dep.getValue() == null || MODE.POSITIVE.getId().equals(dep.getValue().toString());
    switch (dep.getStatus()) {
      case DEFINITELY:
        if (pos) {
          definitelyPosCount++;
          statusMask = statusMask | DEFINITELY_POS_BIT;
        } else {
          definitelyNegCount++;
          statusMask = statusMask | DEFINITELY_NEG_BIT;
        }
        break;
      case DEFEASIBLY:
        if (pos) {
          defeasiblyPosCount++;
          statusMask = statusMask | DEFEASIBLY_POS_BIT;
        } else {
          defeasiblyNegCount++;
          statusMask = statusMask | DEFEASIBLY_NEG_BIT;
        }
        break;
      case DEFEATEDLY:
        if (pos) {
          defeatedlyPosCount++;
          statusMask = statusMask | DEFEATEDLY_POS_BIT;
        } else {
          defeatedlyNegCount++;
          statusMask = statusMask | DEFEATEDLY_NEG_BIT;
        }
        break;
      case UNDECIDABLY:
        throw new IllegalStateException("Individual logical dependencies cannot be undecidably");
    }

    if (rootUndefeated == null) {
      rootUndefeated = node;
      tailUndefeated = node;
    } else {
      if (dep.getStatus() == DefeasibilityStatus.DEFINITELY) {
        // Strict dependencies at to the front
        rootUndefeated.setPrevious(node);
        node.setNext(rootUndefeated);
        rootUndefeated = node;
      } else {
        // add to end
        tailUndefeated.setNext(node);
        node.setPrevious(tailUndefeated);
        tailUndefeated = node;
      }
    }
  }