data-structures

Using string[] as a Dictionary key e.g. Dictionary<string[], StringBuilder>

The structure I am trying to achieve is a composite Dictionary key which is item name and item displayname and the Dictionary value being the combination of n strings So I came up with var pages = new Dictionary<string[], StringBuilder>() { { new string[] { "food-and-drink", "Food & Drink" }, new StringBuilder() }, { new string...

SYSTEM_HANDLE_INFORMATION structure

From where does this structure originates? I know that it is declared in famous ntdll.h and is a part of undocumented windows API. But isn't it vary between different versions of windows? Is there a way to dump this structure from working system? I tried 'dt SYSTEM_HANLDE_INFORMATION' in Windbg and 'type SYSTEM_HANLDE_INFORMATION' in Sof...

DataSetProvider - DataSet to ClientDataSet

EDIT: It seems as if the DataSetProvider doesn't have the functionality I need for this project, so I'll be implementing a custom class for loading the data into the ClientDataSet. I am trying to take data from a TMSQuery which is connected to my DB and populate a ClientDataSet with some of that data using a DataSetProvider. My problem...

Double indirection and structures passed into a function

I am curious why this code works: typedef struct test_struct { int id; } test_struct; void test_func(test_struct ** my_struct) { test_struct my_test_struct; my_test_struct.id=267; *my_struct = &my_test_struct; } int main () { test_struct * main_struct; test_func(&main_struct); printf("%d\n",main_struct->id); } This works, but...

passing groups of properties from 1 class to another

I have a group of 13 properties in a class. I created a struct for these properties and passed it to another class. I need to add another 10 groups of these 13 properties. So thats 130 properties in total. What do I do? 1.I could add all 130 properties to the struct. Will this affect performance and readability 2.I could create a lis...

Strange code behaviour?

I have a C code in which I have a structure declaration which has an array of int[576] declared in it. For some reason, i had to remove this array from the structure, So I replaced this array with a pointer as int *ptr; declared some global array of same type, somewhere else in the code, and initialized this pointer by assigning the glo...

How can we visualizat a binary tree in C++

Hi, When I have implemented binary trees , one of the first utilities one writes is a visualization function that given a tree prints it to the screen. using cout function to print it every time like a stack is probleme to me , I can't represent the value of my job . Printing trees properly in ASCII is quite difficult to understand.Mea...

What are the uses of circular buffer?

What are some of the uses of circular buffer? What are the benefits of using a circular buffer? is it an alternative to double linked list? ...

Parsing a file with hierarchical structure in Python

I'm trying to parse the output from a tool into a data structure but I'm having some difficulty getting things right. The file looks like this: Fruits Apple Auxiliary Core Extras Banana Something Coconut Vegetables Eggplant Rutabaga You can see that top-level items are indented by one space, and it...

data structure problems

hey guys, please help me in finding the optimized solutions to these interesting data structure questions: given a file containing approx 10 million words, design a data structure for finding the anagrams Write a program to display the ten most frequent words in a file such that your program be efficient in all complexity measures. yo...

Chained Hash Tables vs. Open-Addressed Hash Tables

Can somebody explain the main differences between (advantages / disadvantages) the two implementations? For a library, what implementation is recommended? ...

Accessing structure through pointers [c]

I've got a structure which holds names and ages. I've made a linked-list of these structures, using this as a pointer: aNode *rootA; in my main. Now i send **rootA to a function like so addElement(5,"Drew",&rootA); Because i need to pass rootA by reference so that I can edit it in other functions (in my actual program i have two r...

C++: A variation of priority queue

I need some kind of priority queue to store pairs <key, value>. Values are unique, but keys aren't. I will be performing the following operations (most common first): random insertion; retrieving (and removing) all elements with the least key. random removal (by value); I can't use std::priority_queue because it only supports removin...

How to have struct members accessible in different ways

I want to have a structure token that has start/end pairs for position, sentence, and paragraph information. I also want the members to be accessible in two different ways: as a start/end pair and individually. Given: struct token { struct start_end { int start; int end; }; start_end pos; start_end sent; start_end p...

Need dictionary database

Hi, I am planning to work in TRIE data structure for which I need a dictionary database or a text or word file containing the entire list of english words. It doesnt matter if the size is huge. Larger the better. ...

How are two-dimensional arrays formatted in memory?

In C, I know I can dynamically allocate a two-dimensional array on the heap using the following code: int** someNumbers = malloc(arrayRows*sizeof(int*)); for (i = 0; i < arrayRows; i++) { someNumbers[i] = malloc(arrayColumns*sizeof(int)); } Clearly, this actually creates a one-dimensional array of pointers to a bunch of separate ...

Point data structure for a sketching application

I am currently developing a little sketching application based on HTML5 Canvas element. There is one particular problem I haven't yet managed to find a proper solution for. The idea is that the user will be able to manipulate existing stroke data (points) quite freely. This includes pushing point data around (ie. magnet tool) and manipu...

Spatial Index for Rectangles With Fast Insert

Hello, I'm looking for a data structure that provides indexing for Rectangles. I need the insert algorithm to be as fast as possible since the rectangles will be moving around the screen (think of dragging a rectangle with your mouse to a new position). I've looked into R-Trees, R+Trees, kD-Trees, Quad-Trees and B-Trees but from my un...

Generic Data Structure Description Language

I am wondering whether there exists any declarative language for arbitrarily describing the format and semantics of a data structure, that can be compiled to a specific implementation of that structure in any of a set of target languages. That is, something like a generic data definition language but geared toward describing arbitrary da...

Given a 1TB data set on disk with around 1KB per data record, how can I find duplicates using 512MB RAM and infinite disk space?

There is 1TB data on a disk with around 1KB per data record. How to find duplicates using 512MB RAM and infinite disk space? ...