Returns a reversed copy of the map.

@return Map
174911
public function reversed(): Map
    {
        $reversed = new self();
        $reversed->pairs = array_reverse($this->pairs);

        return $reversed;
    }
1214549
public Map<String, Object> getInverse() {

        // lazily create inverse
        if (inverse != null) {
            return inverse;
        }

        // 1)
        inverse = newMap();

        // 2)
        String defaultLanguage = (String) this.get(JsonLdConsts.LANGUAGE);
        if (defaultLanguage == null) {
            defaultLanguage = JsonLdConsts.NONE;
        }

        // create term selections for each mapping in the context, ordererd by
        // shortest and then lexicographically least
        final List<String> terms = new ArrayList<String>(termDefinitions.keySet());
        Collections.sort(terms, new Comparator<String>() {
            @Override
            public int compare(String a, String b) {
                return compareShortestLeast(a, b);
            }
        });

        for (final String term : terms) {
            final Map<String, Object> definition = (Map<String, Object>) termDefinitions.get(term);
            // 3.1)
            if (definition == null) {
                continue;
            }

            // 3.2)
            String container = (String) definition.get(JsonLdConsts.CONTAINER);
            if (container == null) {
                container = JsonLdConsts.NONE;
            }

            // 3.3)
            final String iri = (String) definition.get(JsonLdConsts.ID);

            // 3.4 + 3.5)
            Map<String, Object> containerMap = (Map<String, Object>) inverse.get(iri);
            if (containerMap == null) {
                containerMap = newMap();
                inverse.put(iri, containerMap);
            }

            // 3.6 + 3.7)
            Map<String, Object> typeLanguageMap = (Map<String, Object>) containerMap.get(container);
            if (typeLanguageMap == null) {
                typeLanguageMap = newMap();
                typeLanguageMap.put(JsonLdConsts.LANGUAGE, newMap());
                typeLanguageMap.put(JsonLdConsts.TYPE, newMap());
                containerMap.put(container, typeLanguageMap);
            }

            // 3.8)
            if (Boolean.TRUE.equals(definition.get(JsonLdConsts.REVERSE))) {
                final Map<String, Object> typeMap = (Map<String, Object>) typeLanguageMap
                        .get(JsonLdConsts.TYPE);
                if (!typeMap.containsKey(JsonLdConsts.REVERSE)) {
                    typeMap.put(JsonLdConsts.REVERSE, term);
                }
                // 3.9)
            } else if (definition.containsKey(JsonLdConsts.TYPE)) {
                final Map<String, Object> typeMap = (Map<String, Object>) typeLanguageMap
                        .get(JsonLdConsts.TYPE);
                if (!typeMap.containsKey(definition.get(JsonLdConsts.TYPE))) {
                    typeMap.put((String) definition.get(JsonLdConsts.TYPE), term);
                }
                // 3.10)
            } else if (definition.containsKey(JsonLdConsts.LANGUAGE)) {
                final Map<String, Object> languageMap = (Map<String, Object>) typeLanguageMap
                        .get(JsonLdConsts.LANGUAGE);
                String language = (String) definition.get(JsonLdConsts.LANGUAGE);
                if (language == null) {
                    language = JsonLdConsts.NULL;
                }
                if (!languageMap.containsKey(language)) {
                    languageMap.put(language, term);
                }
                // 3.11)
            } else {
                // 3.11.1)
                final Map<String, Object> languageMap = (Map<String, Object>) typeLanguageMap
                        .get(JsonLdConsts.LANGUAGE);
                // 3.11.2)
                if (!languageMap.containsKey(JsonLdConsts.LANGUAGE)) {
                    languageMap.put(JsonLdConsts.LANGUAGE, term);
                }
                // 3.11.3)
                if (!languageMap.containsKey(JsonLdConsts.NONE)) {
                    languageMap.put(JsonLdConsts.NONE, term);
                }
                // 3.11.4)
                final Map<String, Object> typeMap = (Map<String, Object>) typeLanguageMap
                        .get(JsonLdConsts.TYPE);
                // 3.11.5)
                if (!typeMap.containsKey(JsonLdConsts.NONE)) {
                    typeMap.put(JsonLdConsts.NONE, term);
                }
            }
        }
        // 4)
        return inverse;
    }
561846
public function key()
    {
        $map = $this->__getSerialisablePropertyMap();
        $mapKeys = array_keys($map);
        return $mapKeys[$this->iteratorPosition];
    }
56845
public function reverseTransform($value)
    {  
        if (empty($value)){
            return new ArrayCollection();
        }
        
        if ($this->collection instanceof PersistentCollection){
            foreach ($this->collection as $item){
                $this->om->remove($item);
            }  
            
            $this->collection->clear();
        }

        $data =  explode(',', $value);
        $referenceClass = $this->referenceClass;
        $setInversedProperty = sprintf('set%s', ucfirst($this->inversedProperty));
        
        foreach ($data as $idx => $id){
            $inversedObject = $this->om->getReference($this->inversedClass, (int) $id);
            $referenceObject = new $referenceClass();
            $referenceObject->{$setInversedProperty}($inversedObject);
            $referenceObject->setPosition($idx);
            $this->collection->add($referenceObject);  
        }
        
        return $this->collection;
    }
669174
public function getMapping()
    {
        $mapping = $this->mapping ?? [];

        if ($this::usesSoftDelete() && config('scout.soft_delete', false)) {
            Arr::set($mapping, 'properties.__soft_deleted', ['type' => 'integer']);
        }

        return $mapping;
    }
603658
public Map<Integer, Integer> getReverseNumericMap()
    {
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int newIndex = 0; newIndex < numIndexMap.length; newIndex++)
            map.put(newIndex, numIndexMap[newIndex]);
        return map;
    }
929468
public function getParentMap()
    {
        if (null !== $this->parentMap) {
            return $this->parentMap;
        }

        return $this->parentMap = $this->buildParentMap();
    }
906943
public static <K, V> HashMap<V, List<K>> reverse_map(Map<K, V> map) {
        HashMap<V, List<K>> rtn = new HashMap<V, List<K>>();
        if (map == null) {
            return rtn;
        }
        for (Entry<K, V> entry : map.entrySet()) {
            K key = entry.getKey();
            V val = entry.getValue();
            List<K> list = rtn.get(val);
            if (list == null) {
                list = new ArrayList<K>();
                rtn.put(entry.getValue(), list);
            }
            list.add(key);

        }

        return rtn;
    }
1107358
public static <K, V> Map<V, K> inverse(Map<K, V> map) {
        return inverse(map, false);
    }
43717
@Beta
    public Triple<R, M, L> reversed() {
        return new Triple<>(this.right, this.middle, this.left);
    }
1096753
public function getLastCriterion()
    {
        $count = count($this->map);
        if ($count) {
            $map = array_values($this->map);

            return $map[$count - 1];
        }

        return null;
    }
1127819
public function key()
    {
        if (!$this->valid()) {
            return null;
        }

        if (null === $this->keyMapper) {
            return parent::key();
        }

        $map = $this->keyMapper;
        return $map(parent::key(), parent::current());
    }
438329
public function getReverseDiff()
    {
        $diff = new self();
        $diff->setAddedTables($this->getRemovedTables());
        // idMethod is not set for tables build from reverse engineering
        // FIXME: this should be handled by reverse classes
        foreach ($diff->getAddedTables() as $name => $table) {
            if ($table->getIdMethod() == IDMethod::NO_ID_METHOD) {
                $table->setIdMethod(IDMethod::NATIVE);
            }
        }
        $diff->setRemovedTables($this->getAddedTables());
        $diff->setRenamedTables(array_flip($this->getRenamedTables()));
        $tableDiffs = array();
        foreach ($this->getModifiedTables() as $name => $tableDiff) {
            $tableDiffs[$name] = $tableDiff->getReverseDiff();
        }
        $diff->setModifiedTables($tableDiffs);

        return $diff;
    }
484970
public function getMappings()
    {
        if (isset($this->_mappings)) {
            return $this->_mappings;
        }

        $this->_mappings = array();

        $generatedLine = 1;
        $previousGeneratedColumn = 0;
        $previousOriginalLine = 0;
        $previousOriginalColumn = 0;
        $previousSource = 0;
        $previousName = 0;

        $str = $this->_map->mappings;
        $end = strlen($str);
        $pos = 0;

        while ($pos < $end) {
            if ($str[$pos] === ';') {
                $generatedLine++;
                $pos++;
                $previousGeneratedColumn = 0;
            } else if ($str[$pos] === ',') {
                $pos++;
            } else {
                $mapping = array();
                $mapping['generatedLine'] = $generatedLine;

                // Generated column.
                $value = Kwf_SourceMaps_Base64VLQ::decodePos($str, $pos);
                $mapping['generatedColumn'] = $previousGeneratedColumn + $value;
                $previousGeneratedColumn = $mapping['generatedColumn'];

                if ($pos < $end && !($str[$pos]==',' || $str[$pos]==';')) {
                    // Original source.
                    $value = Kwf_SourceMaps_Base64VLQ::decodePos($str, $pos);
                    $mapping['originalSource'] = (isset($this->_map->sourceRoot) ? $this->_map->sourceRoot.'/' : '')
                                                  . $this->_map->sources[$previousSource + $value];
                    $previousSource += $value;
                    if ($pos >= $end || ($str[$pos]==',' || $str[$pos]==';')) {
                        throw new Exception('Found a source, but no line and column');
                    }

                    // Original line.
                    $value = Kwf_SourceMaps_Base64VLQ::decodePos($str, $pos);
                    $mapping['originalLine'] = $previousOriginalLine + $value;
                    $previousOriginalLine = $mapping['originalLine'];
                    // Lines are stored 0-based
                    $mapping['originalLine'] += 1;
                    if ($pos >= $end || ($str[$pos] == ',' || $str[$pos] == ';')) {
                        throw new Exception('Found a source and line, but no column');
                    }

                    // Original column.
                    $value = Kwf_SourceMaps_Base64VLQ::decodePos($str, $pos);
                    $mapping['originalColumn'] = $previousOriginalColumn + $value;
                    $previousOriginalColumn = $mapping['originalColumn'];

                    if ($pos < $end && !($str[$pos] == ',' || $str[$pos] == ';')) {
                        // Original name.
                        $value = Kwf_SourceMaps_Base64VLQ::decodePos($str, $pos);
                        $mapping['originalName'] = $this->_map->names[$previousName + $value];
                        $previousName += $value;
                    } else {
                        $mapping['originalName'] = null;
                    }
                }
                $this->_mappings[] = $mapping;
            }
        }
        return $this->_mappings;
    }
922337
public BiMap<V, K> inversed() {
        return (inverse == null) ? inverse = new BiMap<>(valueMap, keyMap) : inverse;
    }
106640
public function getMap()
    {
        $vertices = array();
        foreach ($this->vertices as $vertex) {
            $vertices[$vertex->getId()] = $vertex;
        }
        return $vertices;
    }
1328715
public function reverse()
    {
        $result = [];

        foreach ($this->components as $i => $component) {
            $result[$i] = $component * -1;
        }

        return new static($result);
    }