Login  Register

Re: Strange Dictionary behavior

Posted by Ian Bartholomew-19 on Apr 14, 2004; 7:58am
URL: https://forum.world.st/Strange-Dictionary-behavior-tp3370328p3370329.html

Sebastián,

>     In the other hand, when I call the root dictionary stored in the
> database, I get it, it's empty, it's tally is 0, and it looks ready
> for action, but it hasn't those 3 nils and if you make a >>basicSize
> it answer 0, so it is an empty dictionary that can't make an at:put:,
> so it's basically useless.
>
>     What can I do to see what's going on?

I think you're getting mixed up between the implementation and the
interface.

#basicSize (a private method) answers the size of the implementation, the
Object (or whatever) that actually stores the collection.  A lot of
Dolphin's collection classes (Set and it's subclasses for instance) have a
small initial size for efficiency and implementation reasons.

#size answers the size of the interface object, the number of objects that a
user has put in the visible collection.

You can see the same effect with OrderedCollection

x := OrdereredCollection new: 100

creates an OrderedCollection with space preallocated for 100 objects

x basicSize --> 100
x size --> 0
x inspect --> shows 100 nils in the collection
x asArray inspect --> shows an empty Array

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.