Thinking about making a linked-list / tree plugin.

0 favourites
  • 9 posts
From the Asset Store
Make your own platformer for both the web and mobile easy with this Santas Platformer Template, FULLY DOCUMENTED
  • Hey all, <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    I'm considering creating a plugin/behavior that provides linked-lists or tree-style data structures.

    I'm okay with building a list system from scratch if necessary, but if there's any list-type stuff natively accessible from within the C2 runtime, I'm also happy to just use that and avoid reinventing the wheel.

    So if anyone knows off hand...

    1. Does JavaScript have native data structure functionality or libraries?

    2. Does jQuery? (available from C2 runtime I think?)

    3. Should I consider using JSON?

    4. If "yes" to any of the above, are they usable in the C2 runtime?

    It looks to me like there may be generalized data structure tools available natively in JavaScript, and possibly JSON stuff in the standard library.

    (e.g. see "Keyed collections" ... structures)

    But I don't know if it's usable in the C2 runtime, as I'm not sure if there are any important support issues with different versions of JavaScript that I should be aware of.

    Any thoughts or advice welcome. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • 1. javascript has "array", and "object" (hash table)

    2. I used JQuery only when it needs to have a html element. (But not all environments support JQuery I think.)

    3. Yes, since C2 only has number and string type, JSON (string) could be used to store the date structure.

    4. Yes, they all could be used.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the info <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Do you have any advice on which way to go if I want my list/tree interactions to be fast?

    1. I think arrays could work, if I link them together to form more complex structures. The first thing I was considering building was a plugin like the C2 Dictionary, but with each key linking to an array/list instead of a single value. That said, hash tables are actually closer to what I was looking for, so objects might be a good approach as far as performance goes.

    2. Good to know. Yeah, JQuery looked like it was mostly aimed at DOM traversal and other webpage-y stuff.

    3. JSON would be pretty nice if its not too slow.

    1a. Do you know off hand if deleting a property from an object is likely to change its performance?

    Quite a while back, I read about interpreter optimizations that assume that objects are usually used for OOP, for which property deletion is unlikely. With interpreters being optimized for that purpose, interaction with an object takes a permanent performance hit upon the first deletion of a property from that object.

    The only thing I could find about this was a discussion of the Chrome engine from 2009, so it may not be an issue any more:

    (see time 8:16) ... al-Machine

    3a. How fast is JSON compared to using objects for data structure purposes?

    For instance, with JSON, I'm not sure if the underlying code is moving between nodes by following references, or if it is actually parsing its way through large segments of JSON text. I would think that parsing text would be the slower method in general, but even if JSON is doing everything via text, for all I know it could be getting some kind of special treatment by the interpreter.

  • You might consider performance optimize at last.

    The most import thing is how to use this plugin in event sheet.

  • Very good point.

    Thanks again

  • I am not sure what kind of design is suitable for event sheet, since the style of event sheet is not the same as text code.

  • you can use javascript objects as hashtables/dictionaries, with each key being a branch of a tree, and each key can in turn store another object which is also a hastable/dictionary. This wouldn't be difficult at all so read about javascript!

  • Rex/R0j0 has a plugin(Hashtable) that let's you store data in a tree like structure. I think the question asked is wrong.

    "Should I make a Linked List or Tree data structure"

    But instead

    "What data storage do I/you need"

    The second question is a lot more valid and also the question how to use the storage in the event sheet.

    What I will add is this. A depth storage system would be helpful. however Hashtable already accomplishes this However I find Hashtable "string.access.level" style of storage to not so easily usable from an event sheet as it is from traditional programming. But I see no way to make it any easier than it is. Now if you can make depth storage use variable paramater passing that would be a win. Other wise my goto depth storage is still hashtalbe.

  • Like jayderyu said "What data storage do I/you need". You might define your aimed problem first.

    Here is another plugin which has tree nodes.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)