<div>Why are there nils in the middle of the queue?</div>
<div>&nbsp;</div>
<div>The&nbsp;obvious thing is to use a linked structure or one which has amortised constant time addition of elements, and simply count how many items have been added to the queue to limit its size.<br><br>&nbsp;</div>
<div><span class="gmail_quote">On 9/18/08, <b class="gmail_sendername">Ian J Cottee</b> &lt;<a href="mailto:icottee@bluefountain.com">icottee@bluefountain.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hello all<br><br>I&#39;ve got an OrderedCollection that is normally a fixed size (let&#39;s say<br>10 elements). Each element in the collection is another an object or<br>
nil. So for example, at a point in time it might look like<br><br>[nil, nil, Object, nil, Object, Object, nil, nil, Object, nil]<br><br>What I want is to be able to resize the collection. Making it bigger<br>is no problem for me, I can just add nils to the end of the<br>
collection. Making it smaller is involving a little bit of pain. I can<br>see ways of doing it but theyr&#39;e not elegant and I&#39;m sure there are<br>cleaner ways of doing it. If I made the above queue smaller I&#39;d<br>
basically remove the nils starting from the beginning. So a resize to<br>size 7 would give me<br><br>[ Object, Object, Object, nil, nil, Object, nil]<br><br>i.e. the first three nils have been removed.<br><br>Does anybody have any comments on appropriate code to handle this? If<br>
not, I&#39;ll go with the ugly stuff but it would be nice to know the<br>correct SmallTalk way.<br><br>Many thanks for any suggestions.<br><br>Ian<br>_______________________________________________<br>Beginners mailing list<br>
<a href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a><br><a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br>