<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
Hi Levente.<div><br></div><div>It looks like #arraySize is "private" or at least "tests only", right? I understand that you need a better accessor in tests regarding that growth behavior. Well, you could just add #arraySize via meta-programming to the test case where you need it. Hmm... </div><div><br></div><div>So, +1 for fixing #capacity. Not sure about #arraySize though ... :-)</div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div>
<blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
<p style="color: #AAAAAA; margin-top: 10px;">Am 28.09.2020 01:22:39 schrieb commits@source.squeak.org <commits@source.squeak.org>:</p><div style="font-family:Arial,Helvetica,sans-serif">Levente Uzonyi uploaded a new version of Collections to project The Inbox:<br>http://source.squeak.org/inbox/Collections-ul.913.mcz<br><br>==================== Summary ====================<br><br>Name: Collections-ul.913<br>Author: ul<br>Time: 28 September 2020, 1:19:09.686632 am<br>UUID: 03eb89d7-ea1f-4116-99eb-0181542610f7<br>Ancestors: Collections-eem.912<br><br>HashedCollection changes:<br>- make #capacity return the actual capacity of the collection instead of the size of the internal array. This change is obviously not backwards compatible.<br>- introduce #arraySize to return the size of the internal array<br>- improve the performance of #isEmpty when tally is 0<br><br>OrderedDictionary changes;<br>- make it a subclass of PluggableDictionary. This lets one create e.g. an ordered identity dictionary without creating a subclass with duplicated behavior<br>- simplify #initialize and #growTo: now that #capacity is accurate<br><br>=============== Diff against Collections-eem.912 ===============<br><br>Item was added:<br>+ ----- Method: HashedCollection>>arraySize (in category 'accessing') -----<br>+ arraySize<br>+ "Answer the size of the internal array of the receiver."<br>+ <br>+ ^array size!<br><br>Item was changed:<br> ----- Method: HashedCollection>>capacity (in category 'accessing') -----<br> capacity<br>+ "Answer the current capacity of the receiver - aka the number of elements the receiver can hold without growing."<br>- "Answer the current capacity of the receiver."<br> <br>+ ^ array size * 3 // 4!<br>- ^ array size!<br><br>Item was changed:<br> ----- Method: HashedCollection>>isEmpty (in category 'testing') -----<br> isEmpty<br> "For non-weak collections, we can use the tally to speed up the empty check. For weak collections, we must use the traditional way because the tally is unreliable. Also see #size vs. #slowSize."<br> <br>+ tally = 0 ifTrue: [ ^true ].<br>+ ^array class isWeak and: [ super isEmpty ]!<br>- ^ array class isWeak<br>- ifFalse: [ tally = 0 ]<br>- ifTrue: [ super isEmpty ]!<br><br>Item was changed:<br> ----- Method: HashedCollection>>removeAll (in category 'removing') -----<br> removeAll<br> "remove all elements from this collection.<br> Preserve the capacity"<br> <br>+ self initialize: self arraySize!<br>- self initialize: self capacity!<br><br>Item was changed:<br>+ PluggableDictionary subclass: #OrderedDictionary<br>- Dictionary subclass: #OrderedDictionary<br> instanceVariableNames: 'order'<br> classVariableNames: ''<br> poolDictionaries: ''<br> category: 'Collections-Sequenceable'!<br> <br> !OrderedDictionary commentStamp: 'mt 1/16/2015 10:42' prior: 0!<br> I am an ordered dictionary. I have an additional index (called 'order') to keep track of the insertion order of my associations.<br> <br> The read access is not affected by the additional index.<br> <br> The index is updated in O(1) [time] when inserting new keys. For present keys, that insertion involves actions in O(n) to move the respective element to the end of the order.<br> <br> The growth operation compacts the index and takes O(n) additional time.<br> <br> NOTE: This is still no instance of SequenceableCollection. Having this, some protocols are missing and may require working on #associations, which is an Array and thus sequenceable.!<br><br>Item was changed:<br> ----- Method: OrderedDictionary>>growTo: (in category 'private') -----<br> growTo: anInteger<br> <br>- | oldOrder |<br> super growTo: anInteger.<br>+ order := order grownBy: self capacity - order size!<br>- oldOrder := order.<br>- "Grow only to 75%. See #atNewIndex:put: in HashedCollection."<br>- order := self class arrayType new: anInteger + 1 * 3 // 4.<br>- order<br>- replaceFrom: 1<br>- to: tally<br>- with: oldOrder<br>- startingAt: 1!<br><br>Item was changed:<br> ----- Method: OrderedDictionary>>initialize: (in category 'private') -----<br> initialize: n<br> <br> super initialize: n.<br>+ order := self class arrayType new: self capacity!<br>- order := self class arrayType new: n + 1 * 3 // 4!<br><br><br></div></blockquote></div>