Get the oldest items from the queue
@param int $num the number of items to pop
@return Collection
TODO fix situation when crash is immediately after pop;
179328
public function pop(int $num) : Collection
    {
        $ret = new Collection();
        foreach ($this -> iterator as $item) {
            if (!$num--)
                return $ret;
            $ret[] = unserialize(file_get_contents($item));
            unlink($item);
        }
        $this -> updateIterator();
        return $ret;
    }
930598
public function removeArgument($num)
  {
    if ($this->hasArgument($num)) {
      unset($this->arguments[$num]);
    }

    return $this->sortArguments();
  }
807778
public function getLast()
    {
        $last = null;

        if (count($this->objects) > 0) {
            $last = end($this->objects);
        }

        return $last;
    }
589972
public function bottomByPercent($num)
    {
        $count = $this->countData();
        return $this->bottom(round($num*$count/100));
    }
431804
public function limit($num)
    {
        $num = (integer) $num;
        $this->limit = $num;
        $this->mongoCursor->limit($num);
        return $this;
    }
1192818
protected function first()
    {
        foreach ($this->sortable as $key => $value) {
            if (is_numeric($key)) {
                return $value;
            }

            return $key;
        }

        return null;
    }
628100
public function skip($num)
    {
        $num = (integer) $num;
        $this->skip = $num;
        $this->mongoCursor->skip($num);
        return $this;
    }
141055
public function getCall($num)
    {
        if (array_key_exists($num, $this->calls)) {

            return $this->calls[$num];
        }

        return null;
    }
687751
public function natsort(): Collection
    {
        $index = 0;
        $items = $this->items;

        foreach ($items as &$item) {
            $item = [$index++, $item];
        }

        uasort($items, function ($a, $b) {
            $result = strnatcmp($a[1], $b[1]);

            return $result === 0 ? $a[0] - $b[0] : $result;
        });

        foreach ($items as &$item) {
            $item = $item[1];
        }

        return new static($items);
    }
1103446
public function get($num)
    {
        if (isset($this->cache[$num])) {
            return $this->cache[$num];
        }

        return $this->cache[$num] = $this->execute($num);
    }
116188
public function rand($num = 1)
    {
        try {
            $arr = array_rand($this->val(), $num);
        } catch (\ErrorException $e) {
            throw new ArrayObjectException($e->getMessage());
        }

        if (!$this->isArray($arr)) {
            $arr = [$arr];
        }

        return new ArrayObject($arr);
    }
1018076
public function limit($num)
    {
        $num = (integer) $num;
        $this->limit = $num;
        $this->riakCursor->limit($num);
        return $this;
    }
789646
public function ne($num) {
        if (!$this->_isValid) {
            return $this;
        }

        if ($this->_unsafeVar == $num) {
            $this->_isValid = false;
        }
        return $this;
    }
476559
public function random(int $num = 1): CollectionInterface
    {
        if ($this->isEmpty()) {
            return static::make();
        }

        $keys = array_rand($this->toArray(), $num);

        $return = $this->getMultiple((array) $keys);

        return static::make($return);
    }
1023583
private function readAndHashBytes($num)
    {
        $bytes = $this->stream->read($num);
        hash_update($this->hashContext, $bytes);
        return $bytes;
    }
649079
public function getItems()
    {
        uasort(
            $this->items,
            function (AdminMenuItem $first, AdminMenuItem $second) {
                if ($first->getPriority() <= $second->getPriority()) {
                    return 1;
                }

                return -1;
            }
        );

        return $this->items;
    }
636404
public function getFirstItem()
    {
        $results = $this->getItems();

        if (empty($results)) {
            return null;
        }

        $firstItem = reset($results);

        return $firstItem;
    }