SCI Kernel Documentation/List Functions

From SCI Wiki
Revision as of 00:31, 3 December 2015 by Andrew Branscom (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Official SCI Documentation

Chapter: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Index


List Functions

Author: Jeff Stephenson

Revision by: David Slayback

 

Lists play a crucial role in Script code, being the basic component out of which such classes as Collection, List, and Set are built. The kernel list (or kList, as it is known), is simply a block of memory with pointers to the first and last kNodes (kernel nodes) of the list. The kNodes are doubly linked, each having a pointer to both the previous and next node in the list. The nodes also have a key and a value associated with them. The value is the item being stored in the list (an integer, an object ID, etc.) and the key is a means for looking up the value.


(NewList)

Returns a pointer to a new kList with no elements.


(DisposeList kList)

Dispose of a kList. This involves disposing of all kNodes in the list (but not any objects pointed to by the kNode value), then disposing of the kList header itself.


(NewNode key value)

Create a new kNode, set key and value for the kNode, then return a pointer to the new kNode.


(FirstNode kList)

Returns a pointer to the first node in kList, or NULL if kList is empty.


(LastNode kList)

Returns a pointer to the last node in kList, or NULL if kList is empty.


(EmptyList kList)

Returns TRUE if kList is empty, FALSE otherwise.


(NextNode kNode)

Returns the node which follows kNode in a list or NULL if kNode is the last node in the list. Note that this returns the kNode, not the value of that node.


(PrevNode kNode)

Returns the node which precedes kNode in a list or NULL if kNode is the first node in the list. Note that this returns the kNode, not the value of that node.


(NodeValue kNode)

Return the node value of kNode.


(AddAfter kList kNode aNode [key])

Add aNode to kList immediately following kNode (which had better be an element of kList). If key is present, set the key of aNode to its value. Returns aNode.


(AddToFront kList kNode [key])

Add kNode to the front of kList. If key is present, set the key of kNode to its value. Returns kNode.


(AddToEnd kList kNode [key])

Add kNode to the end of kList. If key is present, set the key of kNode to its value. Returns kNode.


(FindKey kList key)

Return the first kNode in kList to have key as its key, or NULL if there is no node with the key.


(DeleteKey kList key)

Delete the first kNode in kList which has key as its key. Return TRUE if a node was deleted, FALSE if no node with the given key was found.

 

Notes


 

Table of Contents

 

< Previous: Resource FunctionsNext: Object Functions >