View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Case Final Project Summer 2007

Fall01 Final Exam Review: Collection Differences

Back to Final Exam Review - Fall2001



a) Arrays best for fixed sized collections, especially when referencing them with numbers.
Arrays are also preferred when you are doing iteration. An OrderedCollection would be perferred over an array if you were adding numbers by index but the number of elements were variable. Jared Parsons

b) Arrays must iterate through structure to compare. Sets are internally hash tables, so only the hash table needs to be searched.

c) OC's are like Java Vectors. It takes a little more overhead. When adding, above some quick internal overhead, when the internal array isn't big enough the array must grow and allocate more memory. When deleting, there must be a point where memory is reclaimed and that means some of the internal array must be moved and recopied.

Matt Quigley

c)
OrderedCollections are slower than Arrays when they are growing. They start off small and double in size every time they run out of room which takes a lot of overhead. OC are almost as fast as Arrays once they have grown to the correct size. OC will always be slower because Arrays at: put: is a primitive and OC's add: it a message and it also does bounds checking.
Jared Parsons



Link to this Page