Bugzilla – Bug 318511
[PATCH] ArrayList:GetRange:ToArray ignores range index
Last modified: 2007-09-15 21:24:06 UTC
---- Reported by flgr@ccan.de 2005-07-13 21:39:17 MST ---- Description of Problem: ArrayList:GetRange(index, count) is optimized. It returns a RangedArrayList which just keeps a reference to the origin array list plus the index and count arguments supplied to it. However, RangedArrayList:ToArray (both with and without a type) does not use its own index argument -- it always defaults to 0 instead. This is evident in the following code: char[] chars = {'a', 'b', 'c', 'd', 'e', 'f'}; ArrayList a = new ArrayList(chars); ArrayList b = a.GetRange(3, 3); object[] obj_chars = b.ToArray (); obj_chars now refers to {'a', 'b', 'c'} instead of {'d', 'e', 'f'}. Steps to reproduce the problem: 1. Run test case from patch. Actual Results: Index ignored, returns first count elements. (Here: {'a', 'b', 'c'}) Expected Results: Index used, returns elements four through six. (Here: {'d', 'e', 'f'}) How often does this happen? Always. ---- Additional Comments From flgr@ccan.de 2005-07-13 21:39:52 MST ---- Created an attachment (id=168248) Fix and test case. ---- Additional Comments From miguel@ximian.com 2005-07-15 10:55:42 MST ---- Florian, please commit both to SVN. ---- Additional Comments From bmaurer@users.sf.net 2005-07-31 17:40:25 MST ---- This was checked in a while ago... Imported an attachment (id=168248) Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>independent</cf_op_sys_details> Unknown operating system unknown. Setting to default OS "Other".