Given a list and an iterate-function that returns
a key for each element in the list (or a property name),
returns an object with an index of each item.

@param mixed $key

@return static
<p>(Immutable)</p>
504043
public function indexBy($key): self
    {
        // init
        $results = [];

        foreach ($this->getGenerator() as $a) {
            if (\array_key_exists($key, $a) === true) {
                $results[$a[$key]] = $a;
            }
        }

        return static::create(
            $results,
            $this->iteratorClass,
            false
        );
    }
982470
static function Get($key) {
	/*//
	@argv string Key
	@argv array(string Key, ...)
	fetch a specific option or list of options.
	//*/

		// if requesting an array of keys, then return an array of values
		// indexed by their respective keys.
		if(is_array($key)) {
			$return = [];

			foreach($key as $k)
			$return[$k] = self::Get($k);

			return $return;
		}

		// else if only asking for one key return the direct value stored
		// in that key.
		else {
			if(array_key_exists($key,self::$Storage))
			return self::$Storage[$key];

			else
			return null;
		}

	}
997657
public function fetch($key) : Collection
    {
        $extr = [];
        foreach ($this->list as $list) {
            if (is_array($list) && key_exists($key, $list)) {
                $extr[] = $list[$key];
            }
        }

        return self::from(...$extr);
    }
211439
public function key($key = null)
    {
        if (!func_num_args()) {
            return $this->_key;
        }
        $this->_key = $key;
        return $this;
    }
457998
protected function indexKey($key)
    {
        $keys = $this->getServiceKeys();

        array_push($keys, $key);

        $keys = array_unique($keys);

        $this->setServiceKeys($keys);

        return $this->getFullKey($key);
    }
1070913
public function offsetGet($key)
    {

        if(is_array($this->__var) && isset($this->__var[$key])){
	        return $this->recursive ? new self($this->__var[$key], true) : $this->__var[$key];
        }

        return false;
    }
1035551
public function extract($key)
    {
        $extracted = [];

        foreach ($this->items as $item) {
            foreach (func_get_args() as $key) {
                if ($item instanceof CollectionInterface) {
                    $extracted[] = $item->get($key);
                } else if (is_object($item)) {
                    $extracted[] = $item->{$key};
                } else {
                    $extracted[] = $item[$key];
                }
            }
        }

        return $extracted;
    }
594217
public function chainingGetMethod($key)
    {
        $newCollection = new self();

        foreach ($this->items as $item) {
            // This item is a collection
            if ($item instanceof self) {
                foreach ($item as $subItem) {
                    $newCollection->put($newCollection->count(), $subItem->$key);
                }

                continue;
            }

            // The next item in the chain is a collection
            if (is_object($item) && ! $item instanceof self && $item->$key instanceof self) {
                foreach ($item->$key as $subItem) {
                    $newCollection->put($newCollection->count(), $subItem);
                }

                continue;
            }

            $newCollection->put($newCollection->count(), $item->$key);
        }

        return $newCollection;
    }
585147
public function offsetGet($key)
    {
        if (!\is_int($key)) {
            throw new \BadMethodCallException('Attempting to access node list with non-integer');
        }

        if (isset($this->nodes[$key])) {
            return $this->createChildInstance($this->nodes[$key]);
        }

        return $this->createChildInstance();
    }
517549
public function getItem($key) {
		if (is_array($key)) {
			$key = $this->arrayHashFunction($key);
		}
		
		if (isset($this->_models[$key])) {
			return $this->_models[$key];
		}
		
		if (isset($this->_data[$key])) {
			$modelClass = $this->getModel();
			
			$item = $modelClass::factory($this->_data[$key]);
			$item->setCollection($this);
			
			if ($this->hasDatagate()) {
				$item->setDatagate($this->getDatagate());
			}
			
			if ($this->hasLocator()) {
				$item->setLocator($this->getLocator());
			}
			
			$this->_models[$key] = $item;
			
			return $item;
		}
	}
756116
public function withKey($key)
    {
        $this->lastKey = $key;
        $this->keys[$key] = null;

        return $this;
    }
215345
public function findItemByKey(string $key)
    {
        return $this->items->first(function (BaseItem $item, $index) use ($key) {
            return $item->getKey() == $key;
        });
    }
896222
public function getObjectByKey($key)
       {
            if (isset($this->map[$key])) {
                parent::rewind();
                while(parent::valid()) {
                    if (parent::key() === $key) {
                        return parent::current();
                    }
                    parent::next();
                }
            }
       }
1316169
public static function get($key)
    {
        $key = strtoupper($key);

        $list = static::loadConstants();

        if(array_key_exists($key,$list))
            return static::loadConstants()[$key];

        if(static::exist($key))
            return $key;

        // Throw exception.
        static::invalidType();
    }
1018365
private function __key($key)
    {
        if ($key instanceof AnObjectHandlable) {
            $key = $key->getHandle();
        } elseif (gettype($key) == 'object') {
            $key = spl_object_hash($key);
        }

        return $key;
    }
1166679
public function get($key)
	{
		$success = false;
		$value = apc_fetch($key, $success);
		$item = new Item($key);

		if ($success)
		{
			$item->setValue($value);
		}

		return $item;
	}
399360
public function offsetGet($key)
    {
        $result = array_get($this->items, $key);

        if (is_array($result))
            return new static($result);

        return $result;
    }