Flip the keys and the values and return a new Collection.

@performanceCompared true
976797
public function flip(): self
    {
        $collection = Factory::create();
        foreach ($this->items as $key => $value) {
            $collection->set($value, $key);
        }

        return $collection;
    }
1152385
static Collection<Collection<SampleDTO>> sampleDTOs(Results<Sample> samples) {
        return Lists.newArrayList(Iterables.transform(samples, new Function<Results.Row<Sample>, Collection<SampleDTO>>() {

            @Override
            public Collection<SampleDTO> apply(Row<Sample> input) {
                return Collections2.transform(input.getElements(), new Function<Sample, SampleDTO>() {

                    @Override
                    public SampleDTO apply(Sample input) {
                        return new SampleDTO(
                                input.getTimestamp().asMillis(),
                                new ResourceDTO(input.getResource().getId(), unwrapMap(input.getResource().getAttributes())),
                                input.getName(),
                                input.getType(),
                                input.getValue(),
                                input.getAttributes(),
                                input.getContext().getId());
                    }
                });
            }
        }));
    }
137779
public function shuffle()
    {
        $keys = $this->getKeys();
        shuffle($keys);

        return $this->createFrom(array_replace(array_flip($keys), $this->toArray()));
    }
1042553
public function odd(): ArrayCollection
    {
        $items = [];
        $pos = 0;

        foreach ($this->items as $key => $value) {
            if ($pos % 2 === 1) {
                $items[$key] = $value;
            }
            $pos++;
        }

        return new static($items);
    }
1281241
public Keys<K> keys () {
		if (keys == null)
			keys = new Keys(this);
		else
			keys.reset();
		return keys;
	}
717567
protected function convertValue()
    {
        $values = $this->getValue();
        $convertedValues = array();

        if (($values instanceof Collection) || is_array($values)) {
            foreach ($values as $value) {
                if (!is_object($value) || !method_exists($value, 'getId')) {
                    continue;
                }

                $convertedValues[] = $value->getId();
            }
        } elseif (is_object($values) && method_exists($values, 'getId')) {
            $convertedValues[] = $values->getId();
        }

        return $convertedValues;
    }
993095
public function keys()
    {
        $count     = $this->count()->toNative();
        $keysArray = new \SplFixedArray($count);

        foreach ($this->items as $key => $item) {
            $keysArray->offsetSet($key, $item->getKey());
        }

        return new Collection($keysArray);
    }
651153
def convert_items(self, items):
        """"""
        return ((key, self.convert(value, self)) for key, value in items)
1273690
private function iteratorFromKeys(array $keys)
    {
        $values = [];
        $key    = ($this->request->qtype === 'eq')
            ? $this->request->key
            : null;

        foreach ($keys as $value) {
            $entry = new IndexEntry();

            $entry->indexKey  = $key;
            $entry->objectKey = $value;

            $values[] = $entry;
        }

        return new ArrayIterator($values);
    }
1273083
function flip(o) {
    var flipped = { };
    for (var i in o) {
        if (o.hasOwnProperty(i)) {
            flipped[o[i]] = i;
        }
    }
    return flipped;
}
1094615
function flip($key) {
		$ref=&$this->ref($key);
		return $ref=array_combine(array_values($ref),array_keys($ref));
	}
615784
public static <K, V> ImmutableMap<K, V> mapFromPairedKeyValueSequences(
      final Iterable<K> keys, final Iterable<V> values) {
    final ImmutableMap.Builder<K, V> builder = ImmutableMap.builder();
    for (final ZipPair<K, V> pair : zip(keys, values)) {
      builder.put(pair.first(), pair.second());
    }
    return builder.build();
  }
636415
public static <K,V> Map<V,K> array_flip(Map<K,V> map) {
        Map<V,K> flipped = new HashMap<>();
        for(Map.Entry<K,V> entry : map.entrySet()) {
            flipped.put(entry.getValue(), entry.getKey());
        }
        return flipped;
    }
1321614
public static <K, V> Map<K, V> toMap(Iterator<K> keys, Iterator<V> values) {
		return toMap(keys, values, false);
	}
891190
function invert () {
        if (Immutable.Iterable.isIterable(toValues)) {
          toValues = toValues.map(mapInvertValues);
        } else {
          toValues = mapInvertValues(toValues);
        }

        return self;
      }
1332219
public Collection keyCollection() {
        if (keyCollection == null) {
            keyCollection = new AbstractCollectionView() {
                public long size() throws ObjectManagerException {
                    return AbstractTreeMap.this.size();
                }

                public Iterator iterator() throws ObjectManagerException {
                    return makeTreeMapIterator(
                    new AbstractMapEntry.Type() {
                        public Object get(AbstractMapEntry entry) {
                            return entry.key;
                        }
                    });
                }
            };
        }
        return keyCollection;
    }
187312
function (collection, elements, settings, oldIndex, newIndex) {
            for (var i = oldIndex + 1; (i <= newIndex); i++) {
                elements = swapElements(collection, elements, i, i - 1);
            }
            return collection.find(settings.elements_selector);
        }