Version: 0.1.0
Release date: 2003-11-01
Author: HAS
Licence: BSD/MIT
Minimum requirements:
Useful objects (stacks, queues, dictionaries, etc.)
Manual.txt (included in download)
Types
0.1.0
----------------------------------------------------------------------
SUMMARY
Useful objects (stacks, queues, dictionaries, etc.)
----------------------------------------------------------------------
COMMANDS
makeAssociativeList() -- make a case-insensitive associative list [1]
Result : script -- an AssociativeList object
makeAssociativeListConsideringCase() -- make a case-sensitive associative list
Result : script -- an AssociativeList object
makeDict() -- make a case-insensitive dictionary [1] that uses Unicode text keys
Result : script -- a Dictionary object
makeDictConsideringCase() -- make a case-sensitive dictionary that uses Unicode text keys
Result : script -- a Dictionary object
makeSDict() -- make a case-insensitive dictionary that uses string keys
Result : script -- a Dictionary object
makeSDictConsideringCase() -- make a case-sensitive dictionary that uses string keys
Result : script -- a Dictionary object
makeQueue() -- make a new queue
Result : script -- a Queue object
makeStack() -- make a new stack
Result : script -- a Stack object
--
[1] Also commonly referred to as associative arrays, hash arrays, hashes, etc. Dictionaries (unrelated to application dictionaries) are faster, while AssociativeLists can use any values for keys.
----------------------------------------------------------------------
OBJECTS
AssociativeList -- stores values by key, where keys can be anything
Methods:
countItems()
Result : integer -- number of items
itemExists(theKey)
theKey : anything -- item's key
Result : boolean -- does an item exist?
setItem(theKey, val)
theKey : anything -- item's key
val : anything -- item's value
getItem(theKey)
theKey : anything -- item's key
Result : anything -- item's value
deleteItem(theKey)
theKey : anything -- item's key
Result : anything -- item's value
getKeys()
Result : list -- all keys [1]
getValues()
Result : list -- all values [1]
Dictionary -- stores values by key, where keys are strings/Unicode text depending on constructor used [2]
Methods:
countItems()
Result : integer -- number of items
itemExists(keyTxt)
keyTxt : Unicode text -- item's key
Result : boolean -- does an item exist?
setItem(keyTxt, val)
keyTxt : Unicode text -- item's key
val : anything -- item's value
getItem(keyTxt)
keyTxt : Unicode text -- item's key
Result : anything -- item's value
deleteItem(keyTxt)
keyTxt : Unicode text -- item's key
Result : anything -- item's value
getKeys()
Result : list -- all keys [1]
getValues()
Result : list -- all values [1]
Queue -- stores values on a first-in, first-out basis
Methods:
addItem(val) -- add a value to end of queue
val : anything
getItem() -- get the value at the head of queue
Result : anything
removeItem() -- remove and return the value at the head of queue
Result : anything
isEmpty() -- is queue empty?
Result : boolean
Stack -- stores values on a first-in, last-out basis
Methods:
push(val) -- push a value onto top of stack
val : anything
top() -- get the value at top of stack
Result : anything
pop() -- remove and return value at top of stack
Result : anything
isEmpty() -- is stack empty?
Result : boolean
--
[1] The order of keys is always same as order of values. Note, however, that scripts that call these methods shouldn't rely on the returned keys/values being in a particular order (e.g. alphabetical) as this is an unpublished internal implementation detail and could change at any time.
[2] Dictionary keys must be string/Unicode text (depending on constructor used), or values which can be cleanly coerced to string/Unicode text (constants, numbers, strings, file specifications, POSIX files). Dates can be used as keys, but remember that date string formatting varies according to each Mac's International settings so will have poor portability/durability. Aliases can also be used as keys, but if the alias changes (eg if the file is moved or renamed) the key won't change to reflect this. Using lists as keys is not recommended.
----------------------------------------------------------------------
NOTES
- Dictionary objects created with makeDict and makeDictConsideringCase store and compare keys as Unicode text internally. Older versions of AS may contain bugs or insufficient Unicode text support to use this type. Users on older machines may prefer to use makeSDict and makeSDictConsideringCase commands to create dictionary objects which store keys internally as strings.
- Dictionary keys consider diacriticals, hyphens, punctuation and white space but ignore expansion. Keys' classes are ignored; for example, setItem(3, true) and setItem("3", true) are equivalent.
- AssociativeLists consider everything when searching for keys - diacriticals, class, etc, and optionally case. For example, setItem("3",Ętrue) is not equivalent to setItem(3,Ętrue) though setItem(3.0,Ętrue) is. Note that you're somewhat at the mercy of the types involved - for example, the Unicode text type doesn't respect all considering/ignoring constants; mutable types such as lists and records can change at any time. Take care if using these as keys.
----------------------------------------------------------------------
TO DO
- Decide if getValues methods on assoc lists and dicts are kosher or not. (And, if they are, is stating 'order of keys = order of values' in OBJECTS > [1] acceptable?)
- Better AssociativeList performance?
- Change Dicts to use balanced b-tree, skip lists, or some other structure that'd give better performance when adding/removing items [currently O(n^2)]?
- Examples of use
----------------------------------------------------------------------
RELEASES
2003-11-01 -- 0.1.0; first release
----------------------------------------------------------------------
AUTHORS
- HAS
----------------------------------------------------------------------
COPYRIGHT
Copyright (c) 2003 HAS
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.