[Mono-list] Bug fixes for System.Collections.Queue
John Bytheway
jjb48@cam.ac.uk
23 Jan 2005 16:12:23 +0000
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
---1870869256-1804289383-1106496743=:31196
Content-Type: text/plain; format=flowed; charset=ISO-8859-1
While developing an application I encountered some bugs in the
implementation of System.Collections.Queue - growth didn't always work
correctly (e.g. if the Queue was of capacity zero) and both TrimToSize and
the ICollection constructor set _tail incorrectly.
I fixed these problems, and I think here is the correct place to post the
fixes.
I attach diffs for Queue.cs and QueueTest.cs (against the current svn
versions (which don't appear to have changed in a long time)) which fix the
problems and also test for them (QueueTest.cs.diff has mixed line endings
due to using unix diff on a dos file - I hope this isn't a problem).
Let me know if these files are needed in some other format.
John Bytheway
---1870869256-1804289383-1106496743=:31196
Content-Type: text/x-patch; name=Queue.cs.diff
Content-Disposition: attachment; filename=Queue.cs.diff
Content-Description: Queue.cs.diff
Content-Transfer-Encoding: BASE64
NTBjNTAKPCAJCXB1YmxpYyBRdWV1ZShJQ29sbGVjdGlvbiBjb2wpIDogdGhp
cyAoY29sID09IG51bGwgPyAzMiA6IGNvbC5Db3VudCkKLS0tCj4gCQlwdWJs
aWMgUXVldWUoSUNvbGxlY3Rpb24gY29sKSA6IHRoaXMgKGNvbCA9PSBudWxs
ID8gMCA6IGNvbC5Db3VudCkKNTZjNTYKPCAJCQlfdGFpbCA9IF9zaXplOwot
LS0KPiAJCQlfdGFpbCA9IDA7CjIwNGMyMDQKPCAJCQlfdGFpbCA9IF9oZWFk
ICsgX3NpemU7Ci0tLQo+IAkJCV90YWlsID0gMDsKMjEwYTIxMSwyMTIKPiAJ
CQlpZiAobmV3Q2FwYWNpdHkgPT0gX2FycmF5Lkxlbmd0aCkKPiAJCQkJbmV3
Q2FwYWNpdHkrKzsK
---1870869256-1804289383-1106496743=:31196
Content-Type: text/x-patch; name=QueueTest.cs.diff
Content-Disposition: attachment; filename=Queue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