For each element in both of the Lists, operation is evaluated with both elements as parameters.
505486
public static <T1, T2> void forEachInBoth(List<T1> list1, List<T2> list2, Procedure2<? super T1, ? super T2> procedure)
    {
        if (list1 != null && list2 != null)
        {
            int size1 = list1.size();
            int size2 = list2.size();
            if (size1 == size2)
            {
                for (int i = 0; i < size1; i++)
                {
                    procedure.value(list1.get(i), list2.get(i));
                }
            }
            else
            {
                throw new IllegalArgumentException("Attempt to call forEachInBoth with two Lists of different sizes :"
                        + size1
                        + ':'
                        + size2);
            }
        }
    }
625013
public static StackElement unionConfigSets(StackElement root1, StackElement root2)
    {
        StackElement p1,
                         p2,
                         root = null,
                         tail;

        /*******************************************************************/
        /* This loop iterates over both lists until one (or both) has been */
        /* completely processed. Each time around the loop, a stack is     */
        /* removed from one of the lists and possibly added to the new     */
        /* list. The new list is initially kept as a circular list to      */
        /* preserve the sorted ordering in which elements are added to it. */
        /*******************************************************************/
        while (root1 != null && root2 != null)
        {
            /***************************************************************/
            /* Compare the two stacks in front of the lists for equality.  */
            /* We exit this loop when we encounter the end of one (or both)*/
            /* of the stacks or two elements in them that are not the same.*/
            /***************************************************************/
            for (p1 = root1, p2 = root2;
                    p1 != null && p2 != null;
                    p1 = p1.previous, p2 = p2.previous)
            {
                if (p1.state != p2.state)
                {
                    break;
                }
            }

            /***************************************************************/
            /* We now have 3 cases to consider:                            */
            /*    1. The two stacks are equal? Discard one!                */
            /*    2. List 1 stack is prefix of list 2 stack (p1 == null)?  */
            /*       or list 1 stack is less than list 2 stack?            */
            /*       Remove list 1 stack and add it to new list.           */
            /*    3. List 2 stack is either a prefix of list 1 stack, or   */
            /*       it is smaller!                                        */
            /*       Remove list 2 stack and add it to new list.           */
            /***************************************************************/
            if (p1 == p2) /* are both p1 and p2 null? */

            {
                p2 = root2;
                root2 = root2.next;
            }
            else if ((p1 == null)
                    || ((p2 != null) && (p1.state.getNumber() < p2.state.getNumber())))
            {
                p1 = root1;
                root1 = root1.next;

                if (root == null)
                {
                    p1.next = p1;
                }
                else
                {
                    p1.next = root.next;
                    root.next = p1;
                }
                root = p1;
            }
            else
            {
                p2 = root2;
                root2 = root2.next;

                if (root == null)
                {
                    p2.next = p2;
                }
                else
                {
                    p2.next = root.next;
                    root.next = p2;
                }
                root = p2;
            }
        }

        /*******************************************************************/
        /* At this stage, at least one (or both) list has been expended    */
        /* (or was empty to start with).                                   */
        /* If the new list is not empty, turn it into a linear list and    */
        /* append the unexpended list to it, if any.                       */
        /* Otherwise, set the new list to the nonempty list if any!        */
        /*******************************************************************/
        if (root != null)
        {
            tail = root;
            root = root.next;
            tail.next = (root1 == null ? root2 : root1);
        }
        else
        {
            root = (root1 == null ? root2 : root1);
        }

        return root;

    }
42930
public void perform() {
        for (int i = 0; i < operations.size(); i++) {
            operations.get(i).process();
        }
    }
581733
private static void generateAllCombinations(
      List<Filter> result,
      List<Filter> andList,
      List<Filter> nonAndList
  )
  {
    List<Filter> children = ((AndFilter) andList.get(0)).getFilters();
    if (result.isEmpty()) {
      for (Filter child : children) {
        List<Filter> a = Lists.newArrayList(nonAndList);
        a.add(child);
        result.add(new OrFilter(a));
      }
    } else {
      List<Filter> work = new ArrayList<>(result);
      result.clear();
      for (Filter child : children) {
        for (Filter or : work) {
          List<Filter> a = Lists.newArrayList((((OrFilter) or).getFilters()));
          a.add(child);
          result.add(new OrFilter(a));
        }
      }
    }
    if (andList.size() > 1) {
      generateAllCombinations(result, andList.subList(1, andList.size()), nonAndList);
    }
  }
857259
public void iterateAllCombinations (@Nonnull final ICommonsList <DATATYPE> aElements,
                                      @Nonnull final Consumer <? super ICommonsList <DATATYPE>> aCallback)
  {
    ValueEnforcer.notNull (aElements, "Elements");
    ValueEnforcer.notNull (aCallback, "Callback");

    for (int nSlotCount = m_bAllowEmpty ? 0 : 1; nSlotCount <= m_nSlotCount; nSlotCount++)
    {
      if (aElements.isEmpty ())
      {
        aCallback.accept (new CommonsArrayList <> ());
      }
      else
      {
        // Add all permutations for the current slot count
        for (final ICommonsList <DATATYPE> aPermutation : new CombinationGenerator <> (aElements, nSlotCount))
          aCallback.accept (aPermutation);
      }
    }
  }
1265432
public static List<double[]> op(@javax.annotation.Nonnull final List<double[]> a, @javax.annotation.Nonnull final List<double[]> b, @javax.annotation.Nonnull final DoubleBinaryOperator fn) {
    assert a.size() == b.size();
    return IntStream.range(0, a.size()).parallel().mapToObj(i -> {
      assert a.get(i).length == b.get(i).length;
      @javax.annotation.Nonnull final double[] c = new double[a.get(i).length];
      for (int j = 0; j < a.get(i).length; j++) {
        c[j] = fn.applyAsDouble(a.get(i)[j], b.get(i)[j]);
      }
      return c;
    }).collect(Collectors.toList());
  }
725012
function mergeDeepObjects(object1, object2) {
  const keys1 = Object.keys(object1);
  const keys2 = Object.keys(object2);

  let index = -1,
      mergedObject = {},
      key,
      indexOfKey;

  while (++index < keys1.length) {
    key = keys1[index];
    indexOfKey = keys2.indexOf(key);

    if (~indexOfKey) {
      mergedObject[key] = getDeeplyMergedValues(object1[key], object2[key]);

      keys2.splice(indexOfKey, 1);

      continue;
    }

    mergedObject[key] = object1[key];
  }

  if (keys2.length) {
    index = -1;

    while (++index < keys2.length) {
      key = keys2[index];

      mergedObject[key] = object2[key];
    }
  }

  return mergedObject;
}
128274
def list_and_add(a, b):
    
    if not isinstance(b, list):
        b = [b]
    if not isinstance(a, list):
        a = [a]
    return a + b
475630
public static VoltXMLElement mergeTwoElementsUsingOperator(String opName,
                                                               String opElementId,
                                                               VoltXMLElement first,
                                                               VoltXMLElement second) {
        if (first == null || second == null) {
            return first == null ? second : first;
        }
        if (opName == null || opElementId == null) { return null; }

        VoltXMLElement retval = new VoltXMLElement("operation");
        retval.attributes.put( "id", opElementId );
        retval.attributes.put( "optype", opName );
        retval.children.add( first );
        retval.children.add( second );
        return retval;
    }
269693
private static Selector processANDRight(Selector sel0, Selector sel1) {
    if (sel1 instanceof Operator) {
      Operator oper = (Operator) sel1;
      if (oper.getOp() == Selector.OR)
        return makeOR(processANDRight(sel0, oper.getOperands()[0]),
                      processANDRight(sel0, oper.getOperands()[1]));
    }
    // Right operand is not OR (neither is left) so treat both as atoms
    return makeAND(sel0, sel1);
  }
217369
private ArrayList<List<?>> permute(List<?>... lists)
	{

		ArrayList<List<?>> output = new ArrayList<List<?>>();
		if (lists.length == 0)
		{
			output.add(new ArrayList<Object>());
			return output;
		}

		for (List<?> list : lists)
		{
			// We require that the result has as many elements as the number
			// of lists passed - so if a list is empty, add in a single null.
			if (list.size() == 0)
				list.add(null);
		}

		List<?> first = lists[0];
		List<?>[] rest = Arrays.copyOfRange(lists, 1, lists.length);

		for (Object x : first)
		{
			ArrayList<List<?>> permuted = permute(rest);
			for (List<?> tocombine : permuted)
			{
				ArrayList<Object> l = new ArrayList<Object>();
				l.add(x);
				l.addAll(tocombine);
				output.add(l);
			}
		}

		return output;
	}
42994
public void combine(Vector new_filters, int op) throws DBException
    {
        for (Enumeration elems = new_filters.elements(); elems.hasMoreElements();)
        {
            SearchFilter filter = (SearchFilter) elems.nextElement();

            combine(filter, op);
        }
    }
1119184
@Override
  public UnionWeight<W> plus(UnionWeight<W> a, UnionWeight<W> b) {
    if (isZero(a)) return b;
    if (isZero(b)) return a;

    ImmutableList.Builder<W> builder = ImmutableList.builder();
    int cursorA = 0;
    int cursorB = 0;

    while (cursorA < a.size() && cursorB < b.size()) {
      W nextA = a.get(cursorA);
      W nextB = b.get(cursorB);

      int compare = ordering.compare(nextA, nextB);
      if (compare < 0) {
        builder.add(nextA);
        cursorA += 1;
      } else if (compare > 0) {
        builder.add(nextB);
        cursorB += 1;
      } else {
        // compare == 0, they are equal, then merge; because a and b are legal UnionWeights already we know they
        // don't have any duplicates so we can increment both
        builder.add(mergeStrategy.merge(nextA, nextB));
        cursorA += 1;
        cursorB += 1;
      }
    }
    for (; cursorA < a.size(); cursorA++) {
      builder.add(a.get(cursorA));
    }
    for (; cursorB < b.size(); cursorB++) {
      builder.add(b.get(cursorB));
    }
    return makeCheckedFrom(builder.build());
  }
45523
@Override
    public void merge(EvaluationBinary other) {
        if (other.countTruePositive == null) {
            //Other is empty - no op
            return;
        }

        if (countTruePositive == null) {
            //This evaluation is empty -> take results from other
            this.countTruePositive = other.countTruePositive;
            this.countFalsePositive = other.countFalsePositive;
            this.countTrueNegative = other.countTrueNegative;
            this.countFalseNegative = other.countFalseNegative;
            this.rocBinary = other.rocBinary;
        } else {
            if (this.countTruePositive.length != other.countTruePositive.length) {
                throw new IllegalStateException("Cannot merge EvaluationBinary instances with different sizes. This "
                                + "size: " + this.countTruePositive.length + ", other size: "
                                + other.countTruePositive.length);
            }

            //Both have stats
            addInPlace(this.countTruePositive, other.countTruePositive);
            addInPlace(this.countTrueNegative, other.countTrueNegative);
            addInPlace(this.countFalsePositive, other.countFalsePositive);
            addInPlace(this.countFalseNegative, other.countFalseNegative);

            if (this.rocBinary != null) {
                this.rocBinary.merge(other.rocBinary);
            }
        }
    }
62017
private MultiValueMap<String, String> union(MultiValueMap<String, String> map1, MultiValueMap<String, String> map2) {
		MultiValueMap<String, String> union = new LinkedMultiValueMap<String, String>(map1);
		Set<Entry<String, List<String>>> map2Entries = map2.entrySet();
		for (Iterator<Entry<String, List<String>>> entryIt = map2Entries.iterator(); entryIt.hasNext();) {
			Entry<String, List<String>> entry = entryIt.next();
			String key = entry.getKey();
			List<String> values = entry.getValue();
			for (String value : values) {
				union.add(key, value);
			}
		}
		return union;
	}
1272286
def combine(self, node, othernode, op=None, unary_op=None, register=False,
                aliasing_type=False):
        
        if self.result[othernode] is self.builder.UnknownType:
            if node not in self.result:
                self.result[node] = self.builder.UnknownType
            return

        if aliasing_type:
            self.combine_(node, othernode, op or operator.add,
                          unary_op or (lambda x: x), register)
            for a in self.strict_aliases[node]:
                self.combine_(a, othernode, op or operator.add,
                              unary_op or (lambda x: x), register)
        else:
            self.combine_(node, othernode, op or operator.add,
                          unary_op or (lambda x: x), register)
680016
public static <T> List<T> mergeLists(List<T> list1, List<T> list2) {
        List<T> merged = new LinkedList<T>();
        if (list1 != null) {
            merged.addAll(list1);
        }
        if (list2 != null) {
            merged.addAll(list2);
        }
        return merged;
    }