data-structures

Malloc a pointer to a pointer to a structure array by reference

The code below compiles, but immediately crashes for reasons obvious to others, but not to me. I can't seem to get it right, can anyone tell me how to fix this. *array_ref[2] = array[0]; *array_ref[3] = array[1]; It crashes on that part everytime. typedef struct test { char *name; char *last_name; } person; int setName(per...

Standard data structure library in C?

I am looking for standard tried and tested library in C language (Windows platform) which implements data structures like stacks, queues, trees etc. I would prefer to have a source code along with it. Writing a library on my own is possible; however, I feel it may be better to opt for some industry standard implementation which may be o...

MySQL database structure: more columns or more rows?

I'm creating an online dictionary and I have to use three different dictionaries for this purpose: everyday terms, chemical terms, computer terms. I have tree options: 1) Create three different tables, one table for each dictionary 2) Create one table with extra columns, i.e.: id term dic_1_definition dic_2_definition dic_...

DataFormat for DataGridView dataSource

I have data from a CD or Record currently setup like this: class Release //class containing all details of release { public string Artist; //Release Artist public string Title; //Release Title public string Released; //Released (Date) public Image Image; //Image private List<Track> tra...

C++ map insertion and lookup performance and storage overhead

I would like to store a mapping of an integer key to a float value in-memory. I have roughly 130 million keys (and, accordingly, 130 million values). My focus is on lookup performance -- I have to do many, many millions of lookups. The C++ STL library has a map class for associative arrays of this sort. I have several questions abou...

what kind of data structure do i need to implement a hashlist for storing coordinates?

i need to build a position manager class to tell me if a position is available. so i tried this : enter code here public class PositionManager { Hashtable currentPositions = new Hashtable(); void occupiedPosition(int x,int y){ this.currentPositions.put(new Integer("4"),new Integer("5")); this.currentPositions.put(new Int...

sharding a database with hierarchical data structure

I am using MySQL to store my parent-child relation. The data is concentrated in one table and it is really elegant by design. I do not have any problem quering; however the table has grown in size dramatically. I would like to shard or use some techniques to improve the performance of my queries (and joins). How would I do it? Any poin...

DB Architecture : Linking to intersection or to main tables?

Hi, I'm creating fantasy football system on my website but i'm very confuse about how I should link some of my table. Tables The main table is Pool which have all the info about the ruling of the fantasy draft. A standard table User, which contains the usual stuff. Intersection table called pools_users which contains id,pool_id,user...

Can you have hash tables in lisp?

Can you have hash tables or dicts in Lisp? I mean the data structure that is a collection of pairs (key, value) where values can be acceded using keys. ...

How do I represent a hextile/hex grid in memory?

Say I'm building a board game with a hextile grid, like Settlers of Catan: Note that each vertex and edge may have an attribute (a road and settlement above). How would I make a data structure which represents this board? What are the patterns for accessing each tile's neighbors, edges and vertices? ...

Subgraph algorithm

I would like to know if there is an efficient algorithm S = F(v,G) to construct a subgraph S out of a DAG G = (V,E) such that all the paths in S contain the vertex v of V. If so, it is possible to efficiently extend F to F'(N,G) for a set of vertices N. I am open to any data structures for storing the DAG G initially. Actually a condit...

RPG dialogue engine / structure

I've always been interested in the data structures involved in an RPG (Role-Playing Game). In particular, I'm curious about dialogue and events based actions. For example: If I approach an NPC at point x in the game, with items y and quests z, how would I work out what the NPC needs to say? Branching dialogue and responding to player in...

java need storing values in a multi-dimension array. what is the best method to reserve memory space?

Hi at first sorry for my poor grammar. I want to build a simple hierarchical clustering algorithm in Java, so i need to build a similarity matrix, whose ij entry gives the similarity between i and j clusters. The first thought is using int[][] for storing this matrix (each cluster has an ID of type integer). I think that having for ...

Doubly Linked List in a Purely Functional Programming Language

How does one go about doing doubly linked lists in a pure functional language? That is, something like Haskell where you're not in a Monad so you don't have mutation. Is it possible? (Singly linked list is obviously pretty easy). ...

Difference between modifying a structure by reference versus other pointers

I am wondering why a structure pointer seems to be behave differently than a char pointer. typedef struct person_struct { char *name; } person; changeStructName(person * name1) { name1->name = "Robert"; } changeCharName(char * name2) { name2 = "Jose"; } int main() { person * name1; ...

Creating an array of data from a text file with items seperated by hashes/pound-symbols with PHP.

Hello, I have weather forecast data formatted like so: loc_id#location#state#forecast_date#issue_date#issue_time#min_0#max_0#min_1#max_1#min_2#max_2#min_3#max_3#min_4#max_4#min_5#max_5#min_6#max_6#min_7#max_7#forecast_0#forecast_1#forecast_2#forecast_3#forecast_4#forecast_5#forecast_6#forecast_7# 090180#Airey's Inlet#VIC#20091204#20091...

java: Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value?

In Java is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? The idea is simple With a data set ala... A B B C C C I'd like to add each line of text to a Set-like object. Each time that a non-unique text is added to the set I'd like to ...

Multi-Dimensional Data Structures in C#

How do you create a multi-dimensional data structure in C#? In my mind it works like so: List<List<int>> results = new List<List<int>>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { results[i][j] = 0; } } This doesn't work (it throws an ArgumentOutOfRangeException)....

What are data structures in objective c

What are the data structures that we can use in objective c? ...

C : Store and index a HUGH amount of info! School Project

Hi, i need to do a school project in C (I'm really don't know c++ as well). I need a data struct to index each word of about 34k documents, its a lot of words, and need to do some ranking about the words, i already did this project about 2 years ago (i'm pause in the school and back this year) and a i use a hash table of binary tree, bu...