I have a function that searches a string for a substring that may be repeated and returns a skipList object, but the skiplist may sometimes be empty. What is the easiest way to determine if the skipList is, in fact, empty? I don't need to know exactly how many items are in the skipList, just whether or not it has any items ( >= 1 ). I didn't notice a length function for skipLists in the reference manual.
Chris chrscote - Tue Apr 25 12:29:26 EDT 2017 |
Re: Determine if returned skip list is empty Well you can make it empty, calling empty(Skip) ... then you know for sure ...just kidding. The easiest way to determine if a skip is empty is to make a loop:
bool isEmpty(Skip sk) { int i; for i in sk do return false; return true }
Regards, Mathias |
Re: Determine if returned skip list is empty Mathias Mamsch - Tue Apr 25 15:36:27 EDT 2017 Well you can make it empty, calling empty(Skip) ... then you know for sure ...just kidding. The easiest way to determine if a skip is empty is to make a loop:
bool isEmpty(Skip sk) { int i; for i in sk do return false; return true }
Regards, Mathias
I'd prefer using the first one
Chris |
Re: Determine if returned skip list is empty Mathias Mamsch - Tue Apr 25 15:36:27 EDT 2017 Well you can make it empty, calling empty(Skip) ... then you know for sure ...just kidding. The easiest way to determine if a skip is empty is to make a loop:
bool isEmpty(Skip sk) { int i; for i in sk do return false; return true }
Regards, Mathias Thanks for that snippet Mathias. It helped me figure out how to get from one loop of checks into another by checking if the first loop had populated the skip list or not and using it as entry to the next loop if the first checks didn't pass.
TTFN =) |