• 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
request for advice on using Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

request for advice on using Core Data


  • Subject: request for advice on using Core Data
  • From: Wagner Truppel <email@hidden>
  • Date: Wed, 20 Jun 2007 20:40:02 +0200

Hello all,

I'm trying to write an application to animate the way a certain data structure works, as a teaching aid for a course on data structures and algorithms. The data structure in question is called a SquareList and appeared as an article in Dr. Dobbs' May 2003 issue <http:// slawa.homeip.net/books/start.php/Dr.Dobbs/Dr. Dobbs Journal -% 201988-2004.16Years/articles/2003/0305/0305b/0305b.htm>. It's a nifty and easy-to-understand DS and lends itself well to an intro course, right after linked lists.

In essence, it's a "horizontal" doubly-linked list of nodes, each of which has a "vertically hanging" doubly-linked list of nodes. As nodes are inserted and deleted, the DS rebalances itself to look as "square" as possible. As a result, insertions, deletions, and look- ups can be done in amortized time proportional to the square root of the total number of nodes. Finding the minimum and the maximum values stored in the DS can be done in constant time, however.

What I would like to do is to display an animation of the process by which insertions, deletions, look-ups, and rebalancing occur, by moving the nodes around on screen. I first thought of doing this in java, since I'm most familiar with that, but it looks like it's going to be easier to do it using Cocoa and it will also give me a chance to finally do some serious coding with it.

Now, for the questions:

1. is using Core Data a good approach for this? It seems to me that it is, since it will probably help me to decouple the data structure logic from all the drawing and animation, though I'm not quite sure yet about how exactly that's going to happen.

2. should I model the links between the nodes as relationships between them or should I consider each horizontal node an NSArray of vertical nodes (and the square list itself an NSArray of horizontal nodes). Of course, in the second case, I'm not directly dealing with linked lists, but the students don't need to know that (they won't see the code for the application, since that's not the goal I have in mind).

3. I sort of already tried to create a Core Data model using the links idea. I have two entities/classes, Node and TopNode. TopNode is a subclass of Node. I noticed that when I specify that Node is TopNode's parent, they are still both considered to be NSManagedObjects. I guess I don't understand what it means for an entity to be another entity's parent in this context, if they both belong to the same class. I'd be grateful for a brief explanation.

4. Can you suggest a good way to decouple the DS logic from all the drawing and animation? For example, it may happen that the last node from a given vertical list needs to be moved to the top of the next vertical list (it then becomes a TopNode), resulting in a cascading of "shift-right" operations of that sort. Presumably, I could strategically add notifications to the DS logic, which would be received by the appropriate controller object which then would have the view update itself. Can Core Data or some kind of binding be used to automate this process?

Thank you all in advance.
Wagner
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: request for advice on using Core Data
      • From: mmalc Crawford <email@hidden>
  • Prev by Date: Predicate on a string length?
  • Next by Date: Re: request for advice on using Core Data
  • Previous by thread: Predicate on a string length?
  • Next by thread: Re: request for advice on using Core Data
  • Index(es):
    • Date
    • Thread