We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Queues, Stacks & Lists of Objects
Page Index Toggle Pages: 1
Queues, Stacks & Lists of Objects (Read 356 times)
Queues, Stacks & Lists of Objects
Jun 22nd, 2008, 9:10am
 
Is it possible to set up linked structures using standard Processing commands?

Or is it inevitable that I learn Java for this?  (I will happily do that, I'm just a bit wary of unfamiliar syntax)

I'm eager to set up basic utilities for creating and traversing single and doubly linked lists, trees, and other structures.

I'd *love* to be directed to examples.  Thanks very much.


--------------
PS:  The array features in Processing seem strange in that the 'append' and 'shorten' commands only operate on the back end of the array.  If I want to get rid if the first element, it seems that I need to do a triple whammy of 'reverse-shorten-reverse'.  Is that right?
Re: Queues, Stacks & Lists of Objects
Reply #1 - Jun 22nd, 2008, 10:14am
 
You can rely on arrays, like in good old C, but it would be inefficient... Smiley
By default, Processing imports java.util.*, so you have transparent access to Collection interface and its implementations, including ArrayList, LinkedList, HashSet, TreeSet. I point to Java 1.4 syntax because the 1.5 (with generics) isn't supported yet.

The syntax isn't alien, actually, Processing code is Java code, just hiding some syntax points unnecessary to start a quick sketch (wrapping in a class, declaring a static main function to create the object from the class and call it, etc.).
If you google around, you will find lot of java collection tutorials, starting with the official one: Introduction to the Collections Framework.
It might be puzzling at first (lot of classes for seemingly similar functions) but you will sort it out eventually.
Page Index Toggle Pages: 1