Tag Info

New answers tagged

3

The AST should only represent the syntax tree of your language. The objects making up the AST would generally not have any further functionality. Nice things like evaluating the AST or prettyprinting it can be implemented outside. I generally use the Visitor Pattern for these external methods – given that I implement an accept_visitor method for each AST ...


1

In the Boo language, which encourages playing around with ASTs via its metaprogramming facilities, there's an AST node class called CompileUnit that lies at the root of a compile tree. Its children are Module nodes, which represent a single source file, and each Module contains tree nodes corresponding to the AST of the code in that file. You could do ...


0

Here I will assume that the weight is an integer with a (relatively) short range (i.e. [0, N)). The reason being that if you have way too many different weights, then each weight will have so little entries that it is not even worth sorting those entries alphanumerically... I would hash the dictionary by weight and then simply use some tree structure to ...


-1

You should check out Judy Arrays. They are wicked fast, although you will have to manage concurrency handling yourself. http://judy.sourceforge.net/


2

With linear probing (or any probing really) a deletion has to be "soft". This means you need to put in a dummy value that won't match anything the user could search for. Or you would need to rehash every time. Rehashing when too many dummy values build up is still advised. Separate chaining (each bucket is a pointer to a linked list of values) has the ...


2

How to visualise this data model where every node is pointing to a list? Is their a standard approach to visualise any data model, with the given data members and methods of a class? It is a doubly-linked list. The fact that each node "knows" the list is more of an implementation detail than it is a matter of the data model architecture. Possible ...


1

You have large graph and you made it even larger. Martinc C. Martin advised using lathes only when needed, so i will not go into this. One of things that could help you, is tranform your graph into smaller graphs. First simplification that helped me a lot (I worked with road networks of europian states) was "removing" nodes with digree 1 and 2 recursively. ...


0

After looking at the XGList code for a while, I think it's meant to be a doubly-linked list in which each node has a pointer to the list itself (i.e. the object with the head pointer, tail pointer and count of total nodes). Presumably the purpose of this is to allow the list to keep track of its own node count, so retrieving the list's size is a constant ...


0

This is the first time I heard of this data structure. What sized trees are you aiming for? Unless it's just thousands, it's probably not going to matter much which underlying data structure you start with. From Wikipedia, I understand that index-based access to the structure is important. For that reason, I would go with an implementation based on plain ...


1

if space is not of concern and your application can afford to use as many space as you want, I'm thinking of 3-dimensional array (or to be more precise, 2-dimensional array of list) structure 2-dimensional array will represent the screen. Each pixel is an element in the array. Each location in array contains a pointer to a list of shape identifier e.g. ...



Top 50 recent answers are included