Combine an indeterminate state of an internal node with an external node which use indicated combining
algorithm.

@param inState
@param externalNode
@return
435216
private InternalNodeState combineInternalNodeStates(InternalNodeState inState, ExternalNode3 externalNode) {

        ExternalNode3 n1 = inState.getExternalNode();

        ExternalNode3 n = combineExternalNodes(n1, externalNode);

        return new InternalNodeState(n);
    }
1366764
public void readExternal(final ObjectInput in) throws IOException,
                                                          ClassNotFoundException {
        this.size = in.readLong();
        this.nodeId = in.readInt();
    }
325573
public AbstractNode createFromConjunctionClauses(Map<String, AttributeInfo> intervals) throws MIDDParsingException, MIDDException {

        if (intervals == null || intervals.size() == 0) {
            return ExternalNode.newInstance(); // return true-value external node
        }

        // Create edges from intervals
        Map<Integer, AbstractEdge<?>> edges = new HashMap<Integer, AbstractEdge<?>>();
        for (String attrId : intervals.keySet()) {
            int varId = attrMapper.getVariableId(attrId);
            Interval<?> interval = intervals.get(attrId).getInterval();

            Class<?> type = interval.getType();
            AbstractEdge<?> e = EdgeUtils.createEdge(interval);
            edges.put(varId, e);
        }

        List<Integer> lstVarIds = new ArrayList<Integer>(edges.keySet());
        Collections.sort(lstVarIds);

        // create a MIDD path from list of edges, start from lowest var-id
        InternalNode<?> root = null;
        InternalNode<?> currentNode = null;
        AbstractEdge<?> currentEdge = null;

        Iterator<Integer> lstIt = lstVarIds.iterator();
        while (lstIt.hasNext()) {
            Integer varId = lstIt.next();
            AbstractEdge<?> e = edges.get(varId);

            // default is NotApplicable, unless the "MustBePresent" is set to "true"
            String attrId = attrMapper.getAttributeId(varId);
            boolean isAttrMustBePresent = intervals.get(attrId).isMustBePresent;

            InternalNodeState nodeState = new InternalNodeState(isAttrMustBePresent ? DecisionType.Indeterminate : DecisionType.NotApplicable);

            InternalNode<?> node = NodeUtils.createInternalNode(varId, nodeState, e.getType());
            if (root == null) {
                root = node; // root points to the start of the MIDD path
                currentNode = node;
                currentEdge = e;
            } else {
                currentNode.addChild(currentEdge, node);
                currentNode = node;
                currentEdge = e;
            }
        }
        // the tail points to the true clause
        currentNode.addChild(currentEdge, ExternalNode.newInstance()); // add a true-value external node
        return root;
    }
600728
private static void outsideAlgorithm(final double[][] scores, final ProjTreeChart inChart, final ProjTreeChart outChart, 
            boolean singleRoot) {             
        final int n = scores.length;
        final int startIdx = singleRoot ? 1 : 0;         

        if (singleRoot) {
            // Initialize.
            double goalScore = 0.0;
            outChart.updateCell(0, n-1, RIGHT, COMPLETE, goalScore, -1);
            
            // The inside algorithm is effectively doing this...
            //
            // wallScore[r] log+=  inChart.scores[0][r][LEFT][COMPLETE] +
            //                     inChart.scores[r][n-1][RIGHT][COMPLETE] + 
            //                     fracRoot[r];
            //
            // goalScore log+= wallScore[r];            
            for (int r=1; r<n; r++) {
                outChart.updateCell(0, r, RIGHT, INCOMPLETE, goalScore, -1);
            }
            
            // Un-build goal constituents by combining left and right complete
            // constituents, on the left and right respectively. This corresponds to
            // left and right triangles. (Note: this is the opposite of how we
            // build an incomplete constituent.)
            for (int r=1; r<n; r++) {
                // Left child.
                double leftScore = outChart.getScore(0, r, RIGHT, INCOMPLETE) + 
                                   inChart.getScore(r, n - 1, RIGHT, COMPLETE) + 
                                   scores[0][r];
                outChart.updateCell(1, r, LEFT, COMPLETE, leftScore, -1);
                // Right child.
                double rightScore = outChart.getScore(0, r, RIGHT, INCOMPLETE) + 
                                    inChart.getScore(1, r, LEFT, COMPLETE) + 
                                    scores[0][r];
                outChart.updateCell(r, n - 1, RIGHT, COMPLETE, rightScore, -1);
            }
        } else  {
            // Base case.
            for (int d=0; d<2; d++) {
                outChart.updateCell(0, n-1, d, COMPLETE, 0.0, -1);
            }
        }
        
        // Parse.
        for (int width = n - 1; width >= 1; width--) {
            for (int s = startIdx; s < n - width; s++) {
                int t = s + width;
                
                // First create complete items (opposite of inside).
                // -- Left side.
                for (int r=s; r<t; r++) {
                    final int d = LEFT;
                    // Left child.
                    double leftScore = outChart.getScore(s, t, d, COMPLETE) + 
                            inChart.getScore(r, t, d, INCOMPLETE);
                    outChart.updateCell(s, r, d, COMPLETE, leftScore, -1);
                    // Right child.
                    double rightScore = outChart.getScore(s, t, d, COMPLETE) + 
                            inChart.getScore(s, r, d, COMPLETE);
                    outChart.updateCell(r, t, d, INCOMPLETE, rightScore, -1);
                }
                // -- Right side.
                for (int r=s+1; r<=t; r++) {
                    final int d = RIGHT;
                    // Left child.
                    double leftScore = outChart.getScore(s, t, d, COMPLETE) + 
                            inChart.getScore(r, t, d, COMPLETE);
                    outChart.updateCell(s, r, d, INCOMPLETE, leftScore, -1);
                    // Right child.
                    double rightScore = outChart.getScore(s, t, d, COMPLETE) + 
                            inChart.getScore(s, r, d, INCOMPLETE);
                    outChart.updateCell(r, t, d, COMPLETE, rightScore, -1);
                }
                
                // Second create incomplete items (opposite of inside).
                for (int r=s; r<t; r++) {
                    for (int d=0; d<2; d++) {
                        double edgeScore = (d == LEFT) ? scores[t][s] : scores[s][t];
                        // Left child.
                        double leftScore = outChart.getScore(s, t, d, INCOMPLETE)
                                + inChart.getScore(r + 1, t, LEFT, COMPLETE) + edgeScore;
                        outChart.updateCell(s, r, RIGHT, COMPLETE, leftScore, -1);
                        // Right child.
                        double rightScore = outChart.getScore(s, t, d, INCOMPLETE)
                                + inChart.getScore(s, r, RIGHT, COMPLETE) + edgeScore;
                        outChart.updateCell(r + 1, t, LEFT, COMPLETE, rightScore, -1);
                    }
                }
            }
        }
    }
462566
public void internalNodeRemoved( String internalNodeKey ) {
        if (this.snapshot.get().containsProjectionForInternalNode(internalNodeKey)) {
            // identify all the projections which from this internal (aka. federated node) and remove them
            synchronized (this) {
                Snapshot current = this.snapshot.get();
                Snapshot updated = current;
                for (Projection projection : current.getProjections()) {
                    if (internalNodeKey.equalsIgnoreCase(projection.getProjectedNodeKey())) {
                        String externalNodeKey = projection.getExternalNodeKey();
                        removeStoredProjection(externalNodeKey);
                        updated = updated.withoutProjection(externalNodeKey);
                    }
                }
                if (current != updated) {
                    this.snapshot.compareAndSet(current, updated);
                }
            }
        }
    }
567267
private void mergeEntryWithoutSplit(Node node,
            Entry newEntry, long timestamp) {

        Entry nearestEntryToCarriedBuffer =
                node.nearestEntry(newEntry);
        double distanceNearestEntryToBuffer =
                nearestEntryToCarriedBuffer.calcDistance(newEntry);

        BestMergeInNode bestMergeInNode =
                calculateBestMergeInNode(node);

        if (distanceNearestEntryToBuffer < bestMergeInNode.distance) {
            nearestEntryToCarriedBuffer.aggregateEntry(newEntry, timestamp,
                    this.negLambda);
        } else {
            node.mergeEntries(bestMergeInNode.entryPos1,
                    bestMergeInNode.entryPos2);
            node.addEntry(newEntry, timestamp);
        }
    }
684686
public static UnbindFuture combineFutures(UnbindFuture future1, UnbindFuture future2) {
        if (future1 == null || future1.isUnbound()) {
            return future2;
        }
        else if (future2 == null || future2.isUnbound()) {
            return future1;
        }
        else {
            return new CompositeUnbindFuture(Arrays.asList(future1, future2));
        }
    }
57033
public final Node buildNode(Object entity, PersistenceDelegator pd, Object entityId, NodeState nodeState)
    {
        String nodeId = ObjectGraphUtils.getNodeId(entityId, entity.getClass());

        Node node = this.graph.getNode(nodeId);

        // If this node is already there in graph (may happen for bidirectional
        // relationship, do nothing and return null)
        // return node in case has already been traversed.

        if (node != null)
        {
            if (this.generator.traversedNodes.contains(node))
            {
                return node;
            }

            return null;
        }

        node = new NodeBuilder().assignState(nodeState).buildNode(entity, pd, entityId, nodeId).node;
        this.graph.addNode(node.getNodeId(), node);
        return node;

    }
418669
@Override
    public void merge(ROCMultiClass other) {
        if (this.underlying == null) {
            this.underlying = other.underlying;
            return;
        } else if (other.underlying == null) {
            return;
        }

        //Both have data
        if (underlying.length != other.underlying.length) {
            throw new UnsupportedOperationException("Cannot merge ROCBinary: this expects " + underlying.length
                            + "outputs, other expects " + other.underlying.length + " outputs");
        }
        for (int i = 0; i < underlying.length; i++) {
            this.underlying[i].merge(other.underlying[i]);
        }
    }
1076095
@Override
    public DecisionType combine(DecisionType op1, DecisionType op2) {
        if (op1 == DecisionType.Permit || op2 == DecisionType.Permit) {
            return DecisionType.Permit;
        }

        if ((op1 == DecisionType.Indeterminate_DP) || (op2 == DecisionType.Indeterminate_DP)) {
            return DecisionType.Indeterminate_DP;
        }

        if (op1 == DecisionType.Indeterminate_P) {
            if (op2 == DecisionType.Deny || op2 == DecisionType.Indeterminate_D) {
                return DecisionType.Indeterminate_DP;
            } else {
                return DecisionType.Indeterminate_P;
            }
        }

        if (op2 == DecisionType.Indeterminate_P) {
            if (op1 == DecisionType.Deny || op1 == DecisionType.Indeterminate_D) {
                return DecisionType.Indeterminate_DP;
            } else {
                return DecisionType.Indeterminate_P;
            }
        }

        if (op1 == DecisionType.Deny || op2 == DecisionType.Deny) {
            return DecisionType.Deny;
        }

        if (op1 == DecisionType.Indeterminate_D || op2 == DecisionType.Indeterminate_D) {
            return DecisionType.Indeterminate_D;
        }

        return DecisionType.NotApplicable;
    }
213540
function combineContiguousOutputStatements (ast) {
  traverse.traverse(ast, {
    enter: function (node, parent) {
      if (node.type !== 'BlockStatement') {
        return;
      }
      var prev = false;

      node.body = fast.reduce(node.body, function (body, statement) {
        if (
          !body.length ||
          statement.type !== 'ExpressionStatement' ||
          statement.expression.type !== 'AssignmentExpression' ||
          statement.expression.operator !== '+=' ||
          statement.expression.left.type !== 'Identifier' ||
          statement.expression.left.name !== 'html'
        ) {
          prev = false;
          body.push(statement);
          return body;
        }
        else if (!prev) {
          prev = statement;
          body.push(statement);
          return body;
        }
        prev.expression.right = {
          type: 'BinaryExpression',
          operator: '+',
          left: prev.expression.right,
          right: statement.expression.right
        };
        return body;
      }, []);
    }
  });
  return ast;
}
632151
public static Boolean or(Object left, Object right) {
        return (Boolean) InfixOpNode.or(left, right, null);
    }
509460
protected final void merge(final InternalNode<K, V> nodeParent, final int slot, final Node<K, V> nodeFROMx) {
		final InternalNode<K, V> nodeFROM = (InternalNode<K, V>) nodeFROMx;
		final InternalNode<K, V> nodeTO = this;
		final int sizeTO = nodeTO.allocated;
		final int sizeFROM = nodeFROM.allocated;
		// copy keys from nodeFROM to nodeTO
		System.arraycopy(nodeFROM.keys, 0, nodeTO.keys, sizeTO + 1, sizeFROM);
		System.arraycopy(nodeFROM.childs, 0, nodeTO.childs, sizeTO + 1, sizeFROM + 1);
		// add key to nodeTO
		nodeTO.keys[sizeTO] = nodeParent.keys[slot];
		nodeTO.allocated += sizeFROM + 1; // keys of FROM and key of nodeParent
		// remove key from nodeParent
		nodeParent.remove(slot);
		// Free nodeFROM
		tree.freeNode(nodeFROM);
	}
449205
public <E> ObjectGraph generateGraph(E entity, PersistenceDelegator delegator, NodeState state)
    {

        this.builder.assign(this);
        Node node = generate(entity, delegator, delegator.getPersistenceCache(), state);
        this.builder.assignHeadNode(node);
        return this.builder.getGraph();
    }
917044
protected static <I, D> void link(AbstractBaseDTNode<I, D> dtNode, TTTState<I, D> state) {
        assert dtNode.isLeaf();

        dtNode.setData(state);
        state.dtLeaf = dtNode;
    }
850303
public void combine(WSStatistic otherStat) {
        if (!validate(otherStat))
            return;

        DoubleStatisticImpl other = (DoubleStatisticImpl) otherStat;
        count += other.count;
        //TODO: how to update lastSampleTime???
        //if (other.lastSampleTime > lastSampleTime)
        //  lastSampleTime = other.lastSampleTime;
    }
1179487
public void merge(final Vector other) {
	for(int i =0; i<other.size(); i++) {
	    this.merge((ByteRange)other.elementAt(i));
	}
    }