Reintegrate skipped items into main list.

@param Item|null $currentItem item from current iteration
327423
protected function rebuildItemList(?Item $currentItem = null): void
    {
        if (count($this->items) === 0) {
            $this->items = $this->skippedItems;
            $this->skippedItems = new ItemList();
        }

        if ($currentItem instanceof Item) {
            $this->items->insert($currentItem);
        }
    }
426368
private function getNextItem(Tag $item, $items)
    {
        $currentItem = $items[0];

        while ($currentItem !== null and $currentItem !== $item) {
            $currentItem = next($items);
        }

        $next = next($items);

        return $next !== false ? $next : null;
    }
397866
def _restoreItemFromArchive(self):
        """"""
        if self._current_item is None:
            return
        dp = getattr(self._current_item, '_dp', None)
        if dp and dp.archived:
            dp.restore_from_archive(parent=self)
340235
protected function insertBetween($item, Bucket $prev, Bucket $next): void
    {
        $bucket = new ItemBucket($item);

        $prev->setNext($bucket);
        $next->setPrev($bucket);

        $bucket->setPrev($prev);
        $bucket->setNext($next);

        $this->current = $bucket;
        $this->count++;
    }
514170
protected function loadItemsForCurrentPage()
    {
        $items = $this->adapter->getItems($this->getOffset(), $this->itemsCountPerPage, $this->sort);
        if (!($items instanceof \Traversable)) {
            $this->items = new \ArrayIterator($items);
        } else {
            $this->items = $items;
        }
    }
23451
public function refreshIdentifiers(AbstractItem $item)
    {
        $text = $item->getText();

        /** @var Hole $hole */
        foreach ($item->getHoles() as $hole) {
            // stash current id
            $oldId = $hole->getUuid();

            // generate new id for hole
            $hole->refreshUuid();

            // replace placeholder in text
            $text = str_replace('[['.$oldId.']]', '[['.$hole->getUuid().']]', $text);
        }

        $item->setText($text);
    }
289200
function splitListItem(opts: Options, change: Change): Change {
    const { value } = change;
    const currentItem = getCurrentItem(opts, value);
    if (!currentItem) {
        return change;
    }

    const splitOffset = value.startOffset;

    return change.splitDescendantsByKey(
        currentItem.key,
        value.startKey,
        splitOffset
    );
}
1188330
protected function nextItem() {

		if ( $this->args['prev_next'] && $this->current && $this->current < $this->total ) {

			$this->items[] = [
				'type'    => 'next',
				'url'     => $this->buildUrl( $this->args['format'], $this->current + 1 ),
				'content' => $this->args['next_text']
			];
		}
	}
739229
protected function recursiveClone($item)
    {
        if (is_object($item)) {
            return clone $item;
        } elseif (is_array($item)) {
            return array_map([$this, 'recursiveClone'], $item);
        }
        return $item;
    }
1212553
protected function setFound($item, $item2)
    {
        if (isset($this->missing[$item])) {
            unset($this->missing[$item][$item2]);
            if (empty($this->missing[$item])) {
                unset($this->missing[$item]);
            }
        }
    }
74211
public void reindexItems() {
    if (numUnsortedItems > 0) {
      int[] newSortedKeys = Arrays.copyOf(sortedKeys, sortedKeys.length + numUnsortedItems);
      int[] newSortedValues = Arrays.copyOf(sortedValues, sortedValues.length + numUnsortedItems);

      int oldLength = sortedKeys.length;
      for (int i = 0; i < numUnsortedItems; i++) {
        newSortedKeys[i + oldLength] = unsortedKeys[i];
        newSortedValues[i + oldLength] = unsortedValues[i];
      }

      ArrayUtils.sortKeyValuePairs(newSortedKeys, newSortedValues, 0, newSortedKeys.length);

      sortedKeys = newSortedKeys;
      sortedValues = newSortedValues;
      numUnsortedItems = 0;
      
      rebuildKeySet();
    }
  }
1015200
public function rewind()
    {
        $this->current = null;
        foreach ($this->branch as $item) {
            $item->rewind();
        }
        reset($this->branch);
    }
935933
protected function setItemListElementAttribute($items)
    {
        foreach($items as $pos=>$item) {
            $items[$pos] = $this->getNestedContext(ListItem::class, [
                'position' => $pos + 1,
                'item' => $item
            ]);
        }

        return $items;
    }
689296
public function rewind()
    {
        $keys = array_keys($this->items);

        $this->currentKey = !empty($keys) ? reset($keys) : null;
    }
34797
public function getCurrentItems() {
		if ($this->_currentItems === null) {
			$offset = $this->_itemsPerPage * $this->_currentPage - $this->_itemsPerPage;
			
			$this->_currentItems = $this->getAdapter()->getItems($offset, $this->_itemsPerPage);
			
			if (! $this->_currentItems instanceof Traversable) {
				throw new RuntimeException('Data from an adapter must implement the "Traversable" interface');
			}
		}
		
		return $this->_currentItems;
	}
215300
def refresh_items(self):
        
        old_items = self.items[:]# if self._dirty else []
        old_iter_data = self._iter_data# if self._dirty else {}
        iterable = self.windowed_iterable
        pattern_nodes = self.pattern_nodes
        new_iter_data = sortedmap()
        new_items = []

        if iterable is not None and len(pattern_nodes) > 0:
            for loop_index, loop_item in enumerate(iterable):
                iteration = old_iter_data.get(loop_item)
                if iteration is not None:
                    new_iter_data[loop_item] = iteration
                    new_items.append(iteration)
                    old_items.remove(iteration)
                    continue
                iteration = []
                new_iter_data[loop_item] = iteration
                new_items.append(iteration)
                for nodes, key, f_locals in pattern_nodes:
                    with new_scope(key, f_locals) as f_locals:
                        f_locals['loop_index'] = loop_index
                        f_locals['loop_item'] = loop_item
                        for node in nodes:
                            child = node(None)
                            if isinstance(child, list):
                                iteration.extend(child)
                            else:
                                iteration.append(child)
        
        # Add to old items list
        #self.old_items.extend(old_items)
        
        #if self._dirty:
        for iteration in old_items:
            for old in iteration:
                if not old.is_destroyed:
                    old.destroy()

        if len(new_items) > 0:
            expanded = []
            recursive_expand(sum(new_items, []), expanded)
            self.parent.insert_children(self, expanded)

        self.items = new_items# if self._dirty else new_items+old_items
        self._iter_data = new_iter_data
406751
void rollback(ItemData item) throws InvalidItemStateException, RepositoryException
   {
      // remove from changes log (Session pending changes)
      PlainChangesLog slog = changesLog.pushLog(item.getQPath());
      SessionChangesLog changes = new SessionChangesLog(slog.getAllStates(), session);

      for (Iterator<ItemImpl> removedIter = invalidated.iterator(); removedIter.hasNext();)
      {
         ItemImpl removed = removedIter.next();

         QPath removedPath = removed.getLocation().getInternalPath();
         ItemState rstate = changes.getItemState(removedPath);

         if (rstate != null)
         {
            if (rstate.isRenamed() || rstate.isPathChanged())
            {
               // find DELETED
               rstate = changes.findItemState(rstate.getData().getIdentifier(), false, new int[]{ItemState.DELETED});
               if (rstate == null)
               {
                  continue;
               }
            }

            NodeData parent = (NodeData)transactionableManager.getItemData(rstate.getData().getParentIdentifier());
            if (parent != null)
            {
               ItemData persisted =
                  transactionableManager.getItemData(parent, rstate.getData().getQPath().getEntries()[rstate.getData()
                     .getQPath().getEntries().length - 1], ItemType.getItemType(rstate.getData()));

               if (persisted != null)
               {
                  // reload item data
                  removed.loadData(persisted);
               }
            } // else it's transient item
         }
         else if (removed.getData() != null)
         {
            // No states for items left usecase
            ItemData persisted = transactionableManager.getItemData(removed.getData().getIdentifier());

            if (persisted != null)
            {
               // reload item data
               removed.loadData(persisted);
            }
         }

         removedIter.remove();
      }
   }