• 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
Re: Linked List
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linked List


  • Subject: Re: Linked List
  • From: Dave DeLong <email@hidden>
  • Date: Sat, 18 Sep 2010 17:49:56 -0600

While correct, I don't entirely agree. Sometimes you *do* care how a data structure is implemented, depending on what you're going to do with it. For example, cocoa does not include any sort of tree-like structure, so you're left to either 1) build one yourself or 2) try to combine other data structures in such a way as to mimic a tree. If you end up building one yourself (which I would say happens fairly frequently), then you have to think about features your tree will have. Fast lookup? Fast insertion? Fast deletion? Some (maybe all) combination?  Depending on your use of the structure, you definitely care what's going on.

Sometimes you don't want an array because it is a semantically incorrect object that can lead people to abuse it. For example, if you're building something that has a logical flow if steps, you don't necessarily want to represent it as an array, since that implies you supporting random lookup (while your design might only accept sequential lookup). In that case, a singly- or doubly-linked list might be a better choice because it is more semantically correct.

And if you don't want to write one yourself, check out the excellent CHDataStructures framework: http://cocoaheads.byu.edu/code/chdatastructures

Dave

Sent from my iPhone

On Sep 18, 2010, at 5:36 PM, Fritz Anderson <email@hidden> wrote:

> On 18 Sep 2010, at 6:09 PM, email@hidden wrote:
>
>> What is the Cocoa equivalent of a doubly linked list? Should I consider NSMutablearray as the analog?
>
> Yes.
>
> The Foundation data types are distinguished by what they _are_ (ordered collections, unordered collections, dictionaries, strings, dates, data buffers) and not how they are _implemented._ Foundation is free to select any of a number of internal implementations for those generic forms. In fact, it may _change_ the implementation of your collections behind your back, to preserve performance as the collections grow.
>
> There's no "doubly-linked list" because you don't really want a doubly-linked list, you want an ordered collection.
>
>    — F
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Linked List (From: email@hidden)
 >Re: Linked List (From: Fritz Anderson <email@hidden>)

  • Prev by Date: Re: Programmatic View Question
  • Next by Date: Re: Linked List
  • Previous by thread: Re: Linked List
  • Next by thread: Re: Linked List
  • Index(es):
    • Date
    • Thread