Add multiple nodes to the hash with the same weight.

@param array    $nodes   An array of nodes.
@param integer  $weight  The weight to add the nodes with.
161558
public function addNodes($nodes, $weight = 1)
    {
        foreach ($nodes as $node) {
            $this->_nodes[] = array('n' => $node, 'w' => $weight);
            $this->_nodeCount++;

            $nodeIndex = $this->_nodeCount - 1;
            $nodeString = serialize($node);

            $numberOfReplicas = (int)($weight * $this->_numberOfReplicas);
            for ($i = 0; $i < $numberOfReplicas; $i++) {
                $this->_circle[$this->hash($nodeString . $i)] = $nodeIndex;
            }
        }

        $this->_updateCircle();
    }
949028
protected void setKetamaNodes(List<MemcachedNode> nodes) {
    TreeMap<Long, MemcachedNode> newNodeMap =
            new TreeMap<Long, MemcachedNode>();
    int numReps = config.getNodeRepetitions();
    int nodeCount = nodes.size();
    int totalWeight = 0;

    if (isWeightedKetama) {
        for (MemcachedNode node : nodes) {
            totalWeight += weights.get(node.getSocketAddress());
        }
    }

    for (MemcachedNode node : nodes) {
      if (isWeightedKetama) {

          int thisWeight = weights.get(node.getSocketAddress());
          float percent = (float)thisWeight / (float)totalWeight;
          int pointerPerServer = (int)((Math.floor((float)(percent * (float)config.getNodeRepetitions() / 4 * (float)nodeCount + 0.0000000001))) * 4);
          for (int i = 0; i < pointerPerServer / 4; i++) {
              for(long position : ketamaNodePositionsAtIteration(node, i)) {
                  newNodeMap.put(position, node);
                  getLogger().debug("Adding node %s with weight %s in position %d", node, thisWeight, position);
              }
          }
      } else {
          // Ketama does some special work with md5 where it reuses chunks.
          // Check to be backwards compatible, the hash algorithm does not
          // matter for Ketama, just the placement should always be done using
          // MD5
          if (hashAlg == DefaultHashAlgorithm.KETAMA_HASH) {
              for (int i = 0; i < numReps / 4; i++) {
                  for(long position : ketamaNodePositionsAtIteration(node, i)) {
                    newNodeMap.put(position, node);
                    getLogger().debug("Adding node %s in position %d", node, position);
                  }
              }
          } else {
              for (int i = 0; i < numReps; i++) {
                  newNodeMap.put(hashAlg.hash(config.getKeyForNode(node, i)), node);
              }
          }
      }
    }
    assert newNodeMap.size() == numReps * nodes.size();
    ketamaNodes = newNodeMap;
  }
1284007
public function addTags($tags = array())
	{
		if (!is_array($tags)) {
			$tags = func_get_args();
		}
		foreach ($tags as $tagAttributes) {
			$this->addTag($tagAttributes);
		}
	}
870946
public function assignTasksRoles(array $roles)
    {
        foreach ($roles as $roles => $tasks) {
            $tasks = (array) $tasks;
            $roles = (array) $roles;

            foreach ($tasks as $task) {
                $this->builder->buildTask($task)->addRoles($roles);
            }
        }
    }
320985
@Override
  public void put(double[] val, double weight) {
    assert (val.length == elements.length);
    if(weight == 0) {
      return; // Skip zero weights.
    }
    final double nwsum = weight + wsum;
    for(int i = BitsUtil.nextSetBit(dims, 0); i >= 0; i = BitsUtil.nextSetBit(dims, i + 1)) {
      final double delta = val[i] - elements[i];
      final double rval = delta * weight / nwsum;
      elements[i] += rval;
    }
    wsum = nwsum;
  }
105613
public function before($nodes) {
    foreach ($this->nodes as $i => $node) {
      $node->before($i === 0 ? $nodes : clone $nodes);
    }
    return $this;
  }
259811
@Override
    public void add(ImprintNode... nodes) {
        Util.notNull(nodes, "Nodes");
        for (ImprintNode node : nodes) {
            add(node);
        }
    }
31247
function(nodes) {

        if (!nodes) {
            return;
        }

        var self = this;

        self.nodes = [];

        _.each(nodes, function(node) {
            self.nodes.push(new rackspace.Node(self, node));
        });

        self.nodeCount = self.nodes.length;
    }
1076181
public void put(double[] val, double weight) {
    assert (val.length == elements.length);
    if(weight == 0) {
      return; // Skip zero weights.
    }
    final double nwsum = weight + wsum;
    for(int i = 0; i < elements.length; i++) {
      final double delta = val[i] - elements[i];
      final double rval = delta * weight / nwsum;
      elements[i] += rval;
    }
    wsum = nwsum;
  }
519276
public function append(Node $node)
    {

        if (!is_array($this->_children)) {
            $this->_children = [];
        }

        $this->_children[] = $node;
        return $this;
    }
615958
private void computeWeights(Node node) {
    int wsum = 0;
    for(Node child : node.children) {
      computeWeights(child);
      wsum += child.weight;
    }
    node.weight = Math.max(1, wsum);
  }
306084
public function updateNodes(array $nodes, $flush = true)
    {
        foreach ($nodes as $node) {
            $node->setSiterootId($this->siterootId);

            $this->entityManager->persist($node);
        }

        if ($flush) {
            $this->entityManager->flush();
        }

        return $this;
    }
1326343
protected function buildNodeDependencies(array $nodes)
    {
        $this->nodesByPath = [];
        $this->nodesByNodeData = [];
        $this->dependenciesOutgoing = [];
        $this->dependenciesIncoming = [];
        $this->nodesWithoutIncoming = [];

        /** @var Node $node */
        foreach ($nodes as $node) {
            $this->nodesByPath[$node->getPath()][] = $node;
            $this->nodesByNodeData[spl_object_hash($node->getNodeData())] = $node;
            $this->nodesWithoutIncoming[spl_object_hash($node)] = $node;
        }

        /** @var Node $node */
        foreach ($nodes as $node) {
            $nodeHash = spl_object_hash($node);

            // Add dependencies for (direct) parents, this will also cover moved and created nodes
            if (isset($this->nodesByPath[$node->getParentPath()])) {
                /** @var Node $parentNode */
                foreach ($this->nodesByPath[$node->getParentPath()] as $parentNode) {
                    $dependencyHash = spl_object_hash($parentNode);
                    $this->dependenciesIncoming[$nodeHash][$dependencyHash] = $parentNode;
                    $this->dependenciesOutgoing[$dependencyHash][$nodeHash] = $node;
                    unset($this->nodesWithoutIncoming[$nodeHash]);
                }
            }

            // Add a dependency for a moved-to reference
            $movedToNodeData = $node->getNodeData()->getMovedTo();
            if ($movedToNodeData !== null) {
                $movedToHash = spl_object_hash($movedToNodeData);
                if (!isset($this->nodesByNodeData[$movedToHash])) {
                    throw new WorkspaceException('Cannot publish a list of nodes with missing dependency (' . $node->getPath() . ' needs ' . $movedToNodeData->getPath() . ' to be published)', 1416483470);
                }
                $dependencyHash = spl_object_hash($this->nodesByNodeData[$movedToHash]);
                $this->dependenciesIncoming[$nodeHash][$dependencyHash] = $this->nodesByNodeData[$movedToHash];
                $this->dependenciesOutgoing[$dependencyHash][$nodeHash] = $node;
                unset($this->nodesWithoutIncoming[$nodeHash]);
            }
        }
    }
754158
public function merge(array $attributes)
    {
        foreach ($attributes as $name => $value) {
            $this->add($name, $value);
        }
    }
924796
public function addMultiple(array $items)
    {
        foreach ($items as $item) {
            if ($item instanceof RequestException) {
                $this->addException($item);
            } else {
                $this->addResponse($item);
            }
        }
    }
1302146
public function beforeTraverse(array $nodes)
    {
        $keyedNodes = [];

        foreach ($nodes as $node) {
            $hashFunc = $node->getType().'Hash';

            if ( ! method_exists($this, $hashFunc)) {
                $keyedNodes[] = $node;

                continue;
            }

            $keyedNodes[$this->$hashFunc($node)] = $node;
        }

        return $keyedNodes;
    }
1028690
private function addError(array & $errors, string $message, array $nodes)
	{
		$errors[] = ['text' => $message, 'nodes' => $nodes];

		$errorGraph = null;
		foreach ($nodes as $node) {
			if ($errorGraph === null) {
				$errorGraph = $node->getGraph();
			} else {
				$nodeGraph = $node->getGraph();
				if ($nodeGraph !== $errorGraph) {
					$errorGraph = $node->getRootGraph();
					break;
				}
			}
		}

		$errorNodeId = '_error_'.md5($message).'_'.count($errors);
		$errorNode = $errorGraph->createNode($errorNodeId, ['label' => $message, 'type' => 'error']);
		foreach ($nodes as $node) {
			$errorGraph->createEdge(null, $errorNode, $node, ['type' => 'error']);
		}
	}