|
Re: Somthing weird in Set: msg#00067lang.smalltalk.squeak.beginners
It can happen most probably due to problems of hash code. Two objects that are equal SHOULD have same hash code. - either YourObject does define #= but does not define #hash - or you add theObject to theSet, then modify theObject, which has side effect of modifying its hash code, and then theObject cannot be found in theSet (in which case you have a cure: theSet rehash) scanFor: seems to do the right thing: find a slot corresponding to theObject hash, and look further if this slot is already occupied by anotherObject. If storage is sparse enough and hash code are well distributed, this should lead to an efficient access cost near O(1), while Array includes: use a linear search O(n). Nicolas Hilaire Fernandes a écrit : How can the following happen ?
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Somthing weird in Set, Hilaire Fernandes |
|---|---|
| Next by Date: | Re: Somthing weird in Set, Hilaire Fernandes |
| Previous by Thread: | Somthing weird in Set, Hilaire Fernandes |
| Next by Thread: | Re: Somthing weird in Set, Hilaire Fernandes |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |