I'm writing a game where a large number of objects will have "area effects" over a region of a tiled 2D map.
Required features:
Several of these area effects may overlap and affect the same tile
It must be possible to very efficiently access the list of effects for any given tile
The area effects can have arbitrary shapes but will u...
Reading from a pipe:
unsigned int sample_in = 0; //4 bytes - 32bits, right?
unsigned int len = sizeof(sample_in); // = 4 in debugger
while (len > 0)
{
if (0 == ReadFile(hRead,
&sample_in,
sizeof(sample_in),
&bytesRead,
...
What is the best way to obtain a simple, efficient immutable queue data type in Clojure?
It only needs two operations, enqueue and dequeue with the usual semantics.
I considered lists and vectors of course, but I understand that they have comparatively poor performance (i.e. O(n) or worse) for modifications at the end and beginning re...
In a multi-dimensional space, I have a collection of rectangles, all of which are aligned to the grid. (I am using the word "rectangles" loosely - in a three dimensional space, they would be rectangular prisms.)
I want to query this collection for all rectangles that overlap an input rectangle.
What is the best data structure for holdi...
Hi,
I'm building an iPhone app, and am just wondering what's the best way to "send" data from one view to another? For example, if I have a UITableView full of information (table.data), and when pressed I show a "detail view" and want to give the user the option to open up a URL shown in the "detail view" in an in-app web browser, how d...
I'd like to create a component, which consist from a board and its surrounding corner. The size of the board (and therefore also of the border) is defined at run-time. Some examples (board is bright and border is dark):
The board consists of objects of the type BoardCell and the border consists of objects of the type BorderCell. Data s...
Hi all,
I have the following function as the constructor for a class:
template<typename T>
void Pointer<T>::Pointer(T* inPtr)
{
mPtr = inPtr;
if (sRefCountMap.find(mPtr) == sRefCountMap.end()) {
sRefCountMap[mPtr] = 1;
} else {
sRefCountMap[mPtr]++;
}
}
Here is the definition for the map:
static std::map<T*, int> s...
I'm writing some of my own data structures, such as binary and quad trees, and kD-trees. Is it possible to write them in such a way that allows for any number of dimensions?
Something like:
KDTree<2, string> twoDTree = new KDTree<2, string>();
twoDTree[3,4] = "X,Y = (3,4)";
KDTree<4, string> fourDTree = new KDTree<4, string>();
fourDT...
I'm writing a game in which a character moves around on a randomly generated map in real time (as it's revealed.) This leads me an interesting data structures problem. The map is generated as it comes into view, in a circle around the character (probably 20-60 tiles) so where there is data, it is very dense, and all in a grid. Where ther...
I am reading through the binary tree delete node algorithm used in the book Data Structures and Algorithms: Annotated Reference with Examples
on page 34 , case 4(Delete node which has both right and left sub trees), following algorithm described in the book looks doesn't work, probably I may be wrong could someone help me what I am mis...
I have been asked recently in a job interview to develop an algorithm that can determine whether a linked list is cyclical. As it's a linked list, we don't know its size. It's a doubly-linked list with each node having 'next' and 'previous' pointers. A node can be connected to any other node or it can be connected to itself.
The only s...
Hi folks, i would like to trigger an event sometime in the future based on an event that is currently happening. I do not expect the volume to be too high, so i care a lot more about simplicity than performance.
For example:
event A happens. i need event B to happen a day later (not time critical)
system stores a record of event in d...
I need to copy an array to a linked list OR transform the array in a linked list.
How this can be done in .NET (C# or VB)?
Thanks
...
I need to create a tree, constructed of nodes that may have any number (within reason, between 0 and 10 say) of outgoing transitions, like so:
X
/ | \
X X X
/
X
/ \
X X
What sort of tree structure is this? What techniques are there for constructing and ...
I'm having some headaches using Structures and functions that return Nothing in VB.NET.
Let me try to explain here with this code:
Public Class Form1
Structure Test
Dim field1 As String
End Structure
Private Function Foo() As Test
Return Nothing
End Function
Private Sub Form1_Load(ByVal sender As ...
I have tried the following approach:
First I do edge contraction for all the edges in the given set of edges to form a modified graph.
Then I calculate the total number of spanning trees, using the matrix tree theorem, from the modified graph.
I want to know if this method is correct and if there are some other better methods.
...
I am trying to do edge contraction on a graph.
n is the number of vertices in the graph.
The vector f containing pairs of vertices representing an edge contains the edges which are to be contracted.
The graph does not contain any self loops.
Please point out any logical mistakes if any in the code.
If the method is entirely wrong then...
The OCaml standard library has a wonderful Set implementation that uses a very efficient divide-and-conquer algorithm to compute the union of two sets. I believe it takes whole subtrees (not just single elements) from one set and inserts them into the other set, rebalancing when necessary.
I'm wondering if this requires the height infor...
I am developing a web application about books. We all knows that books have different category. So, this category is basic on a sequence of number, for example, 200 = computer related, 800 = history. Each book is beyond to one category only.
Here is the question. I have a category list, it may expand in the future. For example, new tec...
I've been writing tic-tac-toe in a variety of languages as an exercise, and one pattern that has emerged is that every representation I've come up with for the defining valid winning rows has been disappointingly hard-coded. They've generally fallen into two categories:
First, the board is represented as a one- or two-dimensional array...