Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0007296 [Squeak] Collections minor always 02-19-09 03:24 04-18-10 22:05
Reporter lucian3 View Status public  
Assigned To nicolas cellier
Priority normal Resolution fixed  
Status closed   Product Version 3.10.2
Summary 0007296: forceTo:paddingWith: doesn't work with OrderedCollections
Description Evaluate in a workspace and you should get an error indicating you attempted to access a non-existent element in an OrderedCollection:

oc := #(1 2 3) asOrderedCollection.
oc forceTo: 10 paddingWith: nil.
Additional Information
Attached Files  M7296-forceTopadding-nice-test.1.cs [^] (1,193 bytes) 02-24-09 10:49
 M7296-forceTopadding-nice-patch.1.cs [^] (913 bytes) 02-24-09 10:51
 M7296-forceTopadding-nice-test.2.cs [^] (1,935 bytes) 02-26-09 10:57
 M7296-forceTopadding-nice-patch.2.cs [^] (1,470 bytes) 02-26-09 11:06

- Relationships

- Notes
(0012986 - 900 - 1214 - 1214 - 1214 - 1214 - 1214)
nicolas cellier
02-24-09 10:30

Classical distinction between size and capacity...
Some messages assume #new: will answer a collection filled with nil.
This is true in ArrayedCollection but not in all SequenceableCollection.

One solution would be to use a replacement message for #new:
#ofSize: is the right message in this case.
But IMO, #new:withAll: would be also a good one.

forceTo: length paddingWith: elem
    "Force the length of the collection to length, padding
    if necessary with elem. Note that this makes a copy."

    | newCollection copyLen |
    newCollection := self species new: length withAll: elem.
    copyLen := self size min: length.
    newCollection replaceFrom: 1 to: copyLen with: self startingAt: 1.
    ^ newCollection

Of course, #new:withAll: has to be implemented in OrderedCollection class
new: anInteger withAll: anObject
    ^ super basicNew setContents: (Array new: anInteger withAll: anObject)
 
(0012987 - 179 - 233 - 233 - 233 - 233 - 233)
nicolas cellier
02-24-09 10:52

"fix begin"
Installer mantis bug: 7296 fix: 'M7296-forceTopadding-nice-patch.1.cs'.
"fix test"
Installer mantis bug: 7296 fix: 'M7296-forceTopadding-nice-test.1.cs'.
"fix end"
 
(0012993 - 169 - 181 - 181 - 181 - 181 - 181)
nicolas cellier
02-26-09 11:07

I forgot to change forceTo:paddingStartWith: which suffer from same problem.
This is why a version 2 has been uploaded.
I used ofSize: this time just to vary pleasure.
 
(0012994 - 179 - 233 - 233 - 233 - 233 - 233)
nicolas cellier
02-26-09 11:08

"fix begin"
Installer mantis bug: 7296 fix: 'M7296-forceTopadding-nice-patch.2.cs'.
"fix test"
Installer mantis bug: 7296 fix: 'M7296-forceTopadding-nice-test.2.cs'.
"fix end"
 
(0013269 - 64 - 64 - 224 - 224 - 224 - 224)
nicolas cellier
08-24-09 20:07

Fixed in http://source.squeak.org/trunk/Collections-nice.115.mcz [^]
 

- Issue History
Date Modified Username Field Change
02-19-09 03:24 lucian3 New Issue
02-19-09 03:24 lucian3 Status new => assigned
02-19-09 03:24 lucian3 Assigned To  => KenCausey
02-19-09 17:44 KenCausey Assigned To KenCausey =>
02-19-09 17:44 KenCausey Status assigned => new
02-19-09 17:44 KenCausey Category Any => Collections
02-24-09 10:30 nicolas cellier Note Added: 0012986
02-24-09 10:49 nicolas cellier File Added: M7296-forceTopadding-nice-test.1.cs
02-24-09 10:51 nicolas cellier File Added: M7296-forceTopadding-nice-patch.1.cs
02-24-09 10:52 nicolas cellier Note Added: 0012987
02-26-09 10:57 nicolas cellier File Added: M7296-forceTopadding-nice-test.2.cs
02-26-09 11:06 nicolas cellier File Added: M7296-forceTopadding-nice-patch.2.cs
02-26-09 11:07 nicolas cellier Note Added: 0012993
02-26-09 11:08 nicolas cellier Note Added: 0012994
08-24-09 20:07 nicolas cellier Note Added: 0013269
09-03-09 21:10 nicolas cellier Status new => resolved
09-03-09 21:10 nicolas cellier Fixed in Version  => trunk
09-03-09 21:10 nicolas cellier Resolution open => fixed
09-03-09 21:10 nicolas cellier Assigned To  => nicolas cellier
04-18-10 22:05 andreas Status resolved => closed


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
68 total queries executed.
42 unique queries executed.
Powered by Mantis Bugtracker