Generate merged list.

@param string[] $blacklist
@param string[] $whitelist

@return array

@throws LogicException
977724
private function mergeLists(array $blacklist, array $whitelist) : array
    {
        if (count(array_intersect($blacklist, $whitelist)) !== 0) {
            throw new LogicException('Directories can\'t be black- and whitelisted at the same time', 1553780055);
        }

        return array_merge(
            array_fill_keys($blacklist, false),
            array_fill_keys($whitelist, true)
        );
    }
1068109
protected function arrayMergeRecursiveDistinct(array $a, array $b, bool $mergeNumericKeys = false): array
    {
        $merged = $a;

        foreach($b as $key => $value) {
            if (!$mergeNumericKeys && is_numeric($key)) {
                $merged[] = $value;
                continue;
            }
            if (is_array($value) && array_key_exists($key, $merged) && is_array($merged[$key])) {
                $merged[$key] = $this->arrayMergeRecursiveDistinct($merged[$key], $value);
            } else {
                $merged[$key] = $value;
            }
        }

        return $merged;
    }
672787
public static function get_plugin_list($eventlist = array()) {
        if (empty($eventlist)) {
            $eventlist = self::get_all_eventlist();
        }
        $plugins = array_keys($eventlist);
        $return = array();
        foreach ($plugins as $plugin) {
            if ($plugin === 'core') {
                $return[$plugin] = get_string('core', 'tool_monitor');
            } else if (get_string_manager()->string_exists('pluginname', $plugin)) {
                $return[$plugin] = get_string('pluginname', $plugin);
            } else {
                $return[$plugin] = $plugin;
            }
        }

        return $return;
    }
510051
protected function _associations(array $whitelist = [])
    {
        $table = $this->_table();

        $associationConfiguration = [];

        $associations = $table->associations();

        $keys = $associations->keys();
        if (!empty($whitelist)) {
            $keys = array_intersect($keys, array_map('strtolower', $whitelist));
        }
        foreach ($keys as $associationName) {
            $association = $associations->get($associationName);
            $type = $association->type();

            if (!isset($associationConfiguration[$type])) {
                $associationConfiguration[$type] = [];
            }

            $assocKey = $association->getName();
            $associationConfiguration[$type][$assocKey]['model'] = $assocKey;
            $associationConfiguration[$type][$assocKey]['type'] = $type;
            $associationConfiguration[$type][$assocKey]['primaryKey'] = $association->getTarget()->getPrimaryKey();
            $associationConfiguration[$type][$assocKey]['displayField'] = $association->getTarget()->getDisplayField();
            $associationConfiguration[$type][$assocKey]['foreignKey'] = $association->getForeignKey();
            $associationConfiguration[$type][$assocKey]['propertyName'] = $association->getProperty();
            $associationConfiguration[$type][$assocKey]['plugin'] = pluginSplit($association->getClassName())[0];
            $associationConfiguration[$type][$assocKey]['controller'] = $assocKey;
            $associationConfiguration[$type][$assocKey]['entity'] = Inflector::singularize(Inflector::underscore($assocKey));
            $associationConfiguration[$type][$assocKey]['entities'] = Inflector::underscore($assocKey);

            $associationConfiguration[$type][$assocKey] = array_merge($associationConfiguration[$type][$assocKey], $this->_action()->getConfig('association.' . $assocKey) ?: []);
        }

        return $associationConfiguration;
    }
745970
public function assign($values, array $whitelist = null)
    {
        if ($whitelist !== null) {
            $whitelist = array_flip($whitelist);
        }
        if (!is_array($values) and !($values instanceof Traversable)) {
            $givenType = gettype($values) !== 'object' ? gettype($values) : 'instance of ' . get_class($values);
            throw new InvalidArgumentException(
                "Argument \$values in " . get_called_class() . "::assign must contain either array or instance of Traversable, $givenType given."
            );
        }
        foreach ($values as $property => $value) {
            if ($whitelist === null or isset($whitelist[$property])) {
                $this->__set($property, $value);
            }
        }
    }
362111
public function nextList()
    {
        if (!$this->hasNext()) {
            return false;
        }

        if (!isset($this->dataObjectFactory)) {
            throw new \LogicException('setDataObjectFactory must be called before calling nextList.');
        }

        if (!isset($this->objectListQuery)) {
            throw new \LogicException('setByFields must be called before calling nextList.');
        }

        $byFields = clone $this->objectListQuery;
        $range = Range::nextRange($this);
        $byFields->setRange($range);

        return $this->dataObjectFactory->selectRequest($byFields);
    }
370412
private Collection<InetSocketAddress> buildWhiteListCollection(String whiteList)
    {
        String[] list = whiteList.split(Constants.COMMA);
        Collection<InetSocketAddress> whiteListCollection = new ArrayList<InetSocketAddress>();

        PersistenceUnitMetadata persistenceUnitMetadata = kunderaMetadata.getApplicationMetadata()
                .getPersistenceUnitMetadata(getPersistenceUnit());
        Properties props = persistenceUnitMetadata.getProperties();
        int defaultPort = 9042;

        if (externalProperties != null && externalProperties.get(PersistenceProperties.KUNDERA_PORT) != null)
        {
            try
            {
                defaultPort = Integer.parseInt((String) externalProperties.get(PersistenceProperties.KUNDERA_PORT));
            }
            catch (NumberFormatException e)
            {
                logger.error("Port in persistence.xml should be integer");
            }
        }

        else
        {
            try
            {
                defaultPort = Integer.parseInt((String) props.get(PersistenceProperties.KUNDERA_PORT));
            }
            catch (NumberFormatException e)
            {
                logger.error("Port in persistence.xml should be integer");
            }
        }

        for (String node : list)
        {
            if (node.indexOf(Constants.COLON) > 0)
            {
                String[] parts = node.split(Constants.COLON);
                whiteListCollection.add(new InetSocketAddress(parts[0], Integer.parseInt(parts[1])));
            }
            else
            {
                whiteListCollection.add(new InetSocketAddress(node, defaultPort));
            }
        }
        return whiteListCollection;
    }
1251239
public void setBlacklist(java.util.Collection<String> blacklist) {
        if (blacklist == null) {
            this.blacklist = null;
            return;
        }

        this.blacklist = new java.util.ArrayList<String>(blacklist);
    }
332728
public WordNumberCollectorBundle mergeAll(
            List<WordNumberCollectorBundle> wordNumberCollectorList) {
        for (WordNumberCollectorBundle wordNumberCollector : wordNumberCollectorList)
            merge(wordNumberCollector);
        return this;
    }


    /**
     * Gets word collector.
     *
     * @return the word collector
     */
    public WordItemCollector getWordCollector() {return this.wordCollector;}

    /**
     * Gets number collector.
     *
     * @return the number collector
     */
    public NumberItemCollector getNumberCollector() {return this.numberCollector;}

    @Override
    public String toString() {
        return "WordNumberCollectorBundle{" + "collectorId='" + collectorId +
                '\'' + ", wordCollector=" + wordCollector +
                ", numberCollector=" + numberCollector + '}';
    }
}
889930
private function getTypeNames(array $typeList)
    {
        $translatedList = [];
        foreach ($typeList as $type) {
            $translatedList[] = $this->translator->translate(HolidayType::$NAME[$type]);
        }

        return $translatedList;
    }
461177
private function addToWhiteList(array $whiteList) {
        $current = $this->getWhiteList();
        $current = array_merge($current, $whiteList);
        $this->setWhiteList($current);
    }
1363173
function simplifyWhitelist(whitelist) {
	var results = [];

	if (Array.isArray(whitelist)) {
	  // whitelist is in Simplified format
	  for (var i = 0; i < whitelist.length; i++) {
	    results.push({
	      "id": whitelist[i]
	    });
	  }
	} else {
	  // whitelist is in Verbose format
	  for (var project in whitelist) {
	    var vlist = whitelist[project];
	    for (var i = 0; i < vlist.length; i++) {
	      var id = vlist[i].id;
	      results.push({
	        "id": id,
	        "dependencyPaths": vlist[i].dependencyPaths
	      });
	    }
	  }
	}

	return results;
}
1355647
public static function objToSnakeArray($object, $blackList = [])
    {
        if (!is_object($object)) {
            throw new \InvalidArgumentException('Not an object');
        }

        return array_reduce(
            self::getAllProperties($object, $blackList),
            function (
                array $result,
                \ReflectionProperty $property
            ) use (
                $object
            ) {
                $property->setAccessible(true);

                $field = $property->getName();
                $value = $property->getValue($object);
                $value = self::transformValue($value);

                if ($object instanceof WithNullableFields) {
                    if (is_null($value) && !$object->isNullable($field)) {
                        return $result;
                    }

                    if ($object->isNullable($field) && !$object->isValueChanged($field)) {
                        return $result;
                    }
                } elseif (is_null($value)) {
                    return $result;
                }


                $result[Str::snake($field)] = $value;

                $property->setAccessible(false);

                return $result;
            },
            []
        );
    }
940521
protected function filterList($list)
    {
        $conf = Configuration::getConfig(self::CONFIG_FILE_NAME);
        $disableWhitelisting
            = $conf->getBoolean(self::PROPNAME_DISABLE_WHITELISTING, false);

        if (!isset($this->originalsp['disco.doNotFilterIdps'])
            || !$this->originalsp['disco.doNotFilterIdps']
        ) {
            $list = parent::filterList($list);
            $list = $this->scoping($list);
            if (!$disableWhitelisting) {
                $list = $this->whitelisting($list);
            }
            $list = $this->greylisting($list);
            $list = $this->greylistingPerSP($list, $this->originalsp);
        }

        if (empty($list)) {
            throw new Exception('All IdPs has been filtered out. And no one left.');
        }

        return $list;
    }
382322
function merge(config, extension, separator, whitelist) {
    whitelist = whitelist || [];
    separator = separator || ":";

    Object
        .keys(extension)
        .filter(function (key) {
            return !whitelist.length || whitelist.indexOf(key) !== -1;
        })
        .forEach(function (key) {
            applyKey(config, key.split(separator), extension[key]);
        });

    return config;
}
625791
public List<List<DoubleSolution>> generatePairsFromSolutionList(List<DoubleSolution> solutionList) {
    List<List<DoubleSolution>> subset = new ArrayList<>() ;
    for (int i = 0; i < solutionList.size(); i++) {
      DoubleSolution solution1 = solutionList.get(i);
      for (int j = i + 1; j < solutionList.size(); j++) {
        DoubleSolution solution2 = solutionList.get(j);

        if (!marked.getAttribute(solution1) ||
            !marked.getAttribute(solution2)) {
          List<DoubleSolution> pair = new ArrayList<>(2);
          pair.add(solution1);
          pair.add(solution2);
          subset.add(pair);

          marked.setAttribute(solutionList.get(i), true);
          marked.setAttribute(solutionList.get(j), true);
        }
      }
    }

    return subset ;
  }
796515
public static function flattenList($a)
    {
        if (!isList($a)) {
            return $a;
        }

        do {
            $flatten = false;
            for ($i = 0, $l = sizeof($a); $i < $l; $i++) {
                if (isList($a[$i])) {
                    $flatten = true;
                    break;
                }
            }
            if (!$flatten) {
                break;
            }
            $res = [];
            for ($i = 0; $i < $l; $i++) {
                if (!isList($a[$i])) {
                    // filter empty arrays inside
                    if (!(is_array($a[$i]) && empty($a[$i]))) {
                        $res[] = $a[$i];
                    }
                } else {
                    $res = array_merge($res, (array)$a[$i]);
                }
            }
            $a = $res;
        } while ($flatten);

        return $a;
    }