[Gambas-user] Data Structures like C++

Emil Lenngren emil.lenngren at ...626...
Mon May 21 23:07:29 CEST 2012


Usual implementations of trees does not have restrictions on number of
children. Each node are allocated separately. They use to contain pointers
to the left and right children, and maybe to the parent as well.

I don't see any reason why Graphs should be implemented as a special
Collection. There are as many possible graph representations as there are
graph algorithms, and most of them can be implemented easily. For example,
the most common is "adjacency list":

Class Graph
    nodes As Node[]
End

Class Node
   adjacentNodes As Node[]
   additionalData
End

2012/5/21 tobi <tobiasboege01 at ...1601...>

> On Mon, 21 May 2012, Benoît Minisini wrote:
> > Le 21/05/2012 21:51, Demosthenes Koptsis a écrit :
> > > Basic languages have simple data structures like vars and arrays but
> > > other languages
> > > like c++ with the help of pointers can have advanced data structures
> > > like containers etc...
> > >
> > > see a full list here
> > > http://en.wikipedia.org/wiki/List_of_data_structures
> > >
> > > i wonder if such data structures can be implemented with gambas with
> > > pointers and if such an action have any mean for real life
> > > applications?
> > >
> > > Is it possible to have such data structures in gambas?
> > > How about some of these to be part of the core libraries?
> >
> > Some data structures are missing, but not so many as you may think at
> > first sight.
> >
> > If they are implemented, I don't think they will go inside the
> > interpreter, to keep its size small (it is already too big for my
> > tastes), but in an extern component.
> >
> > * Map/Associative array/Dictionary
> > * Hash
> >
> > Use a Collection in both case. If the key is not a string, you must find
> > a way to identify your key with a unique string.
> >
> > * Multimap
> >
> > Use a Collection whose values are arrays.
> >
> > * List
> >
> > Use an array. Since CPU have now one, two, three... memory caches,
> > arrays as almost always faster than linked lists.
> >
> > * Set
> >
> > One could use a Collection to emulate it: by transforming a value into a
> > string key, we can assume that the value belongs to the set if the
> > collection has something associated with the key.
> >
> > But it would be better to add a Set native class with a native
> > implementation (in C. Stop with C++!).
> >
> > * Multiset
> >
> > Same remarks (the value is associated to its number of occurence in the
> > collection).
> >
> > * Priority queue
> >
> > Is it worth having a native implementation for that? I don't think so. A
> > implementation in Gambas should be enough.
> >
> > * Queue
> > * Deque
> > * Stack
> >
> > Use an Array. The Push() and Pop() methods can help.
> >
> > * String
> >
> > We have strings of characters. Is something else really needed?
> >
> > * Tree
> > * Graph
> >
> > Native implementation of that would be interesting.
> >
> > Any volunteer? :-)
> >
> > --
> > Benoît Minisini
> >
> >
> ------------------------------------------------------------------------------
> > Live Security Virtual Conference
> > Exclusive live event will cover all the ways today's security and
> > threat landscape has changed and how IT managers can respond. Discussions
> > will include endpoint security, mobile security and the latest in malware
> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>
> Heh... I was once working on reversing the collatz conjecture from a given
> integer - using a
> (halfways) binary tree.
>
> Graphs would in fact be interesting to implement but what is to be cleared
> up before anyone could
> think about volunteering:
> * Are trees restricted to their number of children?
> * The same for graphs: restrictions on the number of edges?
>
> The latter, I never used in programming (read of them a bit in
> mathematics). What could they be used
> for generally? Representing town maps? :)
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list