Next / Previous / Contents / TCC Help System / NM Tech homepage

4.23. SkipList.find()

Unlike .match(), the .find() method returns not a child but a generator that visits all children at or after a given key value.

pyskip.py
# - - -   S k i p L i s t . f i n d   - - -

    def find ( self, key ):
        """Return an iterator starting at a given position
        """

As with the .match() method (see Section 4.23, “SkipList.find()), the first step is to find the level-0 predecessor of the desired position. See Section 4.22, “SkipList.__searchCutItem.

pyskip.py
        #-- 1 --
        # [ searchItem  :=  search-point ( 0, key ).links[0] ]
        prevItem    =  self.__searchCutItem ( key )
        searchItem  =  prevItem.links[0]

At this point, all we need to do is to pass the selected _SkipItem to the _SkipListIterator constructor, and return the new iterator to the caller. See Section 4.4, “The _SkipListIterator class”.

pyskip.py
        #-- 2 --
        return _SkipListIterator ( searchItem )