Forums

Posting in these forums is disabled. These forums will be available for archive purposes. Please join the new forums at the links below:

  • yui-support - replaces the `YUI 3.x` and `YUI 3 Gallery` forums.
    We have created the following discussion categories within this group to aid discoverability for these most-used topics:
    • Charts for YUI Charts support.
    • DataTable for YUI DataTable support.
    • Gallery for YUI Gallery support, including support for published Gallery components as well as the Gallery process in general.
    • Tools for support of YUI’s suite of developer tools such as selleck, shifter, grover, yogi, etc.
    • Everything Else for questions that don’t fit one of the categories above, we’ve got you covered here.
  • yui-deprecated - replaces the `YUI 2.x` forum and the forums of other deprecated products (`YUI Doc`, `Builder`, `YUI PHP Loader`, etc.).
  [ 6 posts ]
New Topic | Post Reply | Print view
Previous topic | Next topic

Erik van den Hooven

YUI Contributor

  • Username: t638403
  • Joined: Sun Apr 04, 2010 7:01 am
  • Posts: 3
  • Location: Rotterdam, Netherlands
  • GitHub: t638403
  • Gists: t638403
  • Offline
  • Profile
Tags:
  • A*
  • base
  • datastructures
  • library
  • priority queue
  • queue
  • tree

YUI Datastructures

Post Posted: Thu Mar 29, 2012 8:22 am
Since javascript is able to run server side now a days, the need for datastructures grows. Like tree's, linked lists, priority queues,stacks and what more you have.

At least I need it :-) because I'd like to implement an A* search algorithm to find the shortest path in a map by searching a tree, and therefore I need (among other things) a tree and a priority queue.

I did a quick search for datastructure libraries on the internet and found that not much is available. The few I found where pretty incomplete.

So I decided to write such a lib myself! Is there anybody who can give me some pointers on where to start, what to extend (YUI.Base I guess?) or any information which might come in handy for me...

Thanks in advance!

Juan Ignacio Dopazo

YUI Contributor

  • Offline
  • Profile

Re: YUI Datastructures

Post Posted: Thu Mar 29, 2012 8:25 am
Hey Erik! Sounds interesting. You should drop by #yui on IRC so the guys and I can give you better feedback.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2017
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: YUI Datastructures

Post Posted: Thu Mar 29, 2012 11:35 pm
Indeed, you make a good point, while JavaScript was only on the client side, there had never been such an amount of data to justify any effort on data structures; hashes, which are native to JavaScript were often enough. Now, on the server, with no bandwidth limitations, you can't just improvise.

I would not extend Y.Base, I don't think it would be needed and it would be a big expense. YUI does not require its modules to extend any particular base class. I would start from zero not extending anything (which means implicitly extending JavaScript own Object class).

YUI will require you to wrap your code into modules, which requires each file to be wrapped in a YUI.add() method so that it identifies itself to the rest of the system. If you plan to make it a YUI Gallery module, the build system does it for you. The build system expects a very specific layout of files so please go to the YUI Gallery section of the documentation and read the documents on how to set it all up.

Alberto Santini

YUI Contributor

  • Offline
  • Profile
Tags:
  • list
  • node

Re: YUI Datastructures

Post Posted: Thu Mar 29, 2012 11:51 pm
Hello Erik.

You may give a look at the following snippet:
https://github.com/albertosantini/node- ... ammiNet.js

Once you have a graph with nodes containing the "from", "to" and "cost" attributes, it is easy to handle the adjacent list.

Hope that helps,
IceBox

Erik van den Hooven

YUI Contributor

  • Username: t638403
  • Joined: Sun Apr 04, 2010 7:01 am
  • Posts: 3
  • Location: Rotterdam, Netherlands
  • GitHub: t638403
  • Gists: t638403
  • Offline
  • Profile
Tags:
  • cla
  • github

Re: YUI Datastructures

Post Posted: Fri Mar 30, 2012 5:40 am
Thanks for the info so far!

I made a github account, signed the CLA for Yahoo and currently reading on how to create a YUI module for the gallery.
I will checkout IRC as soon as possible.

I'm a little affraid of native javascript since it can do some counter intuitive stuff which the YUI lib tries to prevent by its core classes. However, a datastructure better be as fast as possible. So I guess I'll follow your advice on that one :-)

I'm going to dive in the code example more thoroughly later. It seems promising to me!

Erik van den Hooven

YUI Contributor

  • Username: t638403
  • Joined: Sun Apr 04, 2010 7:01 am
  • Posts: 3
  • Location: Rotterdam, Netherlands
  • GitHub: t638403
  • Gists: t638403
  • Offline
  • Profile

Re: YUI Datastructures

Post Posted: Sun Apr 15, 2012 7:43 am
I made some progress. If anyone is interested, please criticise!
http://jsfiddle.net/t638403/NdTZN/7/

I implemented Crockford's parasitic inheritence pattern, with shared secrets... (http://youtu.be/DwYPG6vreJg?t=32m59s)

Furthermore, does anyone know a good way to work with exceptions in js?
  [ 6 posts ]
New Topic | Post Reply | Print view
Previous topic | Next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum