Difference between revisions of "SCI Kernel Documentation/List Functions"
(One intermediate revision by the same user not shown) | |||
Line 10: | Line 10: | ||
[[SCI Kernel Documentation/String Functions|6]] | | [[SCI Kernel Documentation/String Functions|6]] | | ||
[[SCI Kernel Documentation/Picture Functions|7]] | | [[SCI Kernel Documentation/Picture Functions|7]] | | ||
− | [[SCI Kernel Documentation/Save | + | [[SCI Kernel Documentation/Save-Restore Game Functions|8]] | |
[[SCI Kernel Documentation/Animation Functions|9]] | | [[SCI Kernel Documentation/Animation Functions|9]] | | ||
[[SCI Kernel Documentation/Graphic Screen Functions|10]] | | [[SCI Kernel Documentation/Graphic Screen Functions|10]] | | ||
Line 29: | Line 29: | ||
| | ||
− | + | 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. | |
+ | |||
+ | ===<br /> (NewList) === | ||
+ | |||
+ | <blockquote> | ||
+ | Returns a pointer to a new kList with no elements. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (DisposeList kList) === | ||
+ | |||
+ | <blockquote> | ||
+ | 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. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (NewNode key value) === | ||
+ | |||
+ | <blockquote> | ||
+ | Create a new kNode, set key and value for the kNode, then return a pointer to the new kNode. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (FirstNode kList) === | ||
+ | |||
+ | <blockquote> | ||
+ | Returns a pointer to the first node in kList, or NULL if kList is empty. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (LastNode kList) === | ||
+ | |||
+ | <blockquote> | ||
+ | Returns a pointer to the last node in kList, or NULL if kList is empty. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (EmptyList kList) === | ||
+ | |||
+ | <blockquote> | ||
+ | Returns TRUE if kList is empty, FALSE otherwise. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (NextNode kNode) === | ||
+ | |||
+ | <blockquote> | ||
+ | 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. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (PrevNode kNode) === | ||
+ | |||
+ | <blockquote> | ||
+ | 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. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (NodeValue kNode) === | ||
+ | |||
+ | <blockquote> | ||
+ | Return the node value of kNode. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (AddAfter kList kNode aNode [key]) === | ||
+ | |||
+ | <blockquote> | ||
+ | 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. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (AddToFront kList kNode [key]) === | ||
+ | |||
+ | <blockquote> | ||
+ | Add kNode to the front of kList. If key is present, set the key of kNode to its value. Returns kNode. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (AddToEnd kList kNode [key]) === | ||
+ | |||
+ | <blockquote> | ||
+ | Add kNode to the end of kList. If key is present, set the key of kNode to its value. Returns kNode. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (FindKey kList key) === | ||
+ | |||
+ | <blockquote> | ||
+ | Return the first kNode in kList to have key as its key, or NULL if there is no node with the key. | ||
+ | </blockquote> | ||
+ | |||
+ | ===<br /> (DeleteKey kList key) === | ||
+ | |||
+ | <blockquote> | ||
+ | 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. | ||
+ | </blockquote> | ||
| | ||
Line 48: | Line 132: | ||
[[Category:SCI Documentation]] | [[Category:SCI Documentation]] | ||
[[Category:Kernel Functions]] | [[Category:Kernel Functions]] | ||
+ | [[Category:List Functions]] |
Latest revision as of 00:31, 3 December 2015
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
< Previous: Resource FunctionsNext: Object Functions >