From: Robert Klemme Date: 2005-05-02T05:09:26+09:00 Subject: Re: collections with values of fixed classes/lengths "Eric Mahurin" schrieb im Newsbeitrag news:20050501180414.24582.qmail@web41115.mail.yahoo.com... > Anybody know of any collection (i.e. Array/Hash) classes where > the keys and/or values can be assigned a fixed class? And for > classes that have variable length objects the length be also > potentially fixed across the collection? The main purpose of > doing this would be memory usage. You wouldn't have to store > the class (and possibly object length and pointer to allocated > space) per element and instead just have the raw data in the > collection. You would be able to get the same memory > utilization as C per element if done right. > > Here would be a few examples of what I'm talking about and how > much space per element it would take: > > - array of Floats (64 bits per element) > - array of N-bit integers (N bits per element) For numerics there is for narray: http://raa.ruby-lang.org/project/narray > - hash of 2-character strings (2*8 bits per key and Object per > value) > - array of array of 8 Floats (8*64 bits per line) There's also pack and unpack which can be used to implement this. > For dealing with large data structures, this could be > invaluable for memory usage. "could" or "is"? Do you really know that you need this or is this just guessing? Kind regards robert