1

I need to find which link among turtle links is the oldest or newest , now I am using a property called , link-order which stores this value for each link and I find it using min-of my-out-links [link-order]

Is there any better way to do this? Without the need to have link-order attribute for all the links?

Marzy
  • 1,884
  • 16
  • 24

1 Answers1

1

The only alternative I can think of would be to have a global list of all links, and whenever a link is created, stick it on the end (and remove any nobody entries that have accumulated because of links dying). Then the oldest link is always the first item in the list.

Your original idea seems fine to me too though — neither approach seems obviously superior to the other. I'd probably pick your idea just because it seems a little simpler and less error-prone to code.

Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
  • Thanks for your answer, I will use the current method until I find a better one, but I think the method you are suggesting can be used for the oldest link among all the links for all the turtles, which is not what I need, for each turtle I need the oldest link. In suggested method we should have a row for each turtle and the ordered set of links for that turtle, and first item of each row then will be the oldest for that turtle. – Marzy Nov 06 '13 at 22:39