Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We need Priority Queue, Queue and Stack! #305

Open
gogo40 opened this issue Mar 3, 2013 · 4 comments
Open

We need Priority Queue, Queue and Stack! #305

gogo40 opened this issue Mar 3, 2013 · 4 comments

Comments

@gogo40
Copy link
Member

gogo40 commented Mar 3, 2013

Hi, I think we need more STL objects like Prioirty Queue, Queue and Stack and a "generic" Map.

function comparator(var a, var b) {
          return lexicographic_compare(a, b);
}

var o = Class.new(3, 4, 5);
var m = GenericMap.new(comparator);

m[Class.new(3, 4, 5)] = o;

var pQ = PriorityQueue.new(comparator);
pQ.push(o);

while (!pQ.empty()) {
         var u = pQ.top(); pQ.pop();
         pQ.push(Class.new(3, 4));
}

@felipensp
Copy link
Member

I've started with the std.collection module. Initially have added Stack class.

@gogo40
Copy link
Member Author

gogo40 commented Mar 4, 2013

We need set<>, multiset. list and multimap too! And iterator!

@gogo40
Copy link
Member Author

gogo40 commented Mar 4, 2013

@felipensp great work!

@gogo40
Copy link
Member Author

gogo40 commented Mar 4, 2013

I think we need some collection operations:

//Array and List operations
a =[ 3];
a += [1];   // result =  [3,1]
a += [3];   // result  =  [3, 1, 3]
a += [3, 4, 5, 6]; // result = [ 3, 1, 3, 3, 4, 5, 6]
a = [3] + [ 4];  // result =  [3, 4]

//Set operations
a = { 3 , 4} + {3, 5, 6}; // result =  {3, 4, 5, 6}
a = a - { 5 , 3}; // result = { 4, 6}
a -= {4}; // result = {6}
a -= {7}; // resutl = {6}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants