• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSArray.subList() implementation broken?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSArray.subList() implementation broken?


  • Subject: NSArray.subList() implementation broken?
  • From: Q <email@hidden>
  • Date: Tue, 13 Mar 2007 01:08:53 +1000

Is it just me or does the NSArray.subList() implementation return too many elements.

I have the following code:

Object[] list = {"1", "2", "3", "4", "5"};
ArrayList  list1 = new ArrayList(Arrays.asList(list));
NSArray list2 = new NSArray(list);
               
System.out.println(list1);
System.out.println(list2);
System.out.println(list1.subList(0, 1));
System.out.println(list2.subList(0, 1));

and it produces:

[1, 2, 3, 4, 5]
("1", "2", "3", "4", "5")
[1]
("1", "2")


The sun definition of List.subList is:
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

The NSArray behaviour is "toIndex inclusive", which is wrong.

Can someone else confirm this is the case?  I would otherwise just use subArrayWithRange, but the code I am working with needs to use the List collection interface.


-- 

Seeya...Q


Quinton Dolan - email@hidden

Gold Coast, QLD, Australia

Ph: +61 419 729 806



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSArray.subList() implementation broken?
      • From: Gavin Eadie <email@hidden>
    • Re: NSArray.subList() implementation broken?
      • From: Florijan Stamenkovic <email@hidden>
  • Prev by Date: Re: Ajax Updates
  • Next by Date: Re: Ajax Updates
  • Previous by thread: Re: WebObjects 4.5.1 DST problems with NSGregorianDate
  • Next by thread: Re: NSArray.subList() implementation broken?
  • Index(es):
    • Date
    • Thread