data-structures

Bidirectional Map in .NET

Is there a .NET data structure I could use for bidirectional lookup? Here's the problem: Serialization. My object contains a field which points to one of 10 predefined static objects. When writing to the file, I write a single character representing which of the 10 objects is being referenced. At this point, I need a lookup datastructur...

Data structure for Objects

Which data structures I should store the real life 'objects' in? I am not looking for computer representation. I am looking for different data structures for different item in real life access/storage etc. Is there any study on this? Update: Based upon comments, I should remove the 'data' from data structures and simply looking for st...

How to deal with animating in-between states when the model is discrete

The data model in my program has a number of discrete states, but I want to animate the transition between these states. While the animation is going on, what the user sees on the screen is disconnected from what the underlying data is like. Once the animation is complete, they match up again. For example, let's say we have a simple gam...

Architecture advice for a website.

I'm looking for a bit of advice with regards to the structure of an application I'm tasked with. I need to have a series of webforms to store some data, most of the data is the same but each form would have some differeing data depending on the form used. Would a base class then a series of classes inheriting from this for the specific...

Iterating over a data structure with 51 million primes quickly.

What's the best data structure (in java) for the task of loading 51 million primes and then iterating over them? I need to know, for example, the primes that are between 1000000000 and that same number minus 100000. ...

C Library for compressing sequential positive integers

Hi, I have the very common problem of creating an index for an in-disk array of strings. In short, I need to store the position of each string in the in-disk representation. For example, a very naive solution would be an index array as follows: uint64 idx[] = { 0, 20, 500, 1024, ..., 103434 }; Which says that the first string is at po...

selection of data structure

i am using C++ say i want to store 40 records( usrnames) i will simply use array if i want to store 40000 records ( usrnames) . i will search it sequentially which data structure should i use? any thoughts? ...

Does a lock-free queue "multiple producers-single consumer" exist for Delphi?

I've found several implementations for single producer-single consumer, but none for multiple producer-single consumer. Does a lock-free queue for "multiple producers-single consumer" exist for Delphi? ...

Mysql B+ Tree implementation

Mysql uses B+ tree for implementing indexes. Lets say my primary index is of type (name, age, city). Can someone throw some light how Mysql implements a B+ tree on these kinds of keys ? My hunch is that it treats the whole tuple as a key and it treats it like a partial order. Eg: (John, 24, New Jersey) < (John, 24, New York) < (John, ...

Returning multiple values from a C function

Important: Please see this very much related question: Return multiple values in C++. I'm after how to do the same thing in ANSI C? Would you use a struct or pass the addresses of the params in the function? I'm after extremely efficient (fast) code (time and space), even at the cost of readability. EDIT: Thanks for all the answers. Ok...

How does Python store lists internally?

How are lists in python stored internally? Is it an array? A linked list? Something else? Or does the interpreter guess at the right structure for each instance based on length, etc. If the question is implementation dependent, what about the classic CPython? ...

Asking for opinion for my MenuTree structure. Which is better, array or delimiter approach?

Which is the better API? I think the latter approach is better because strings are interned. But I'm pining for succintness. Which do you think is better? [Task("Assortment", Author = "好先生", MenuTree = "The>Quick>Brown>Megan")] public partial class Form1 : MycForm, ITaskPlugin { } or this(strings can be interned): [Task("As...

should a tree node have a pointer to its containing tree?

I'm building a gui component that has a tree-based data model (e.g. folder structure in the file system). so the gui component basically has a collection of trees, which are just Node objects that have a key, reference to a piece of the gui component (so you can assign values to the Node object and it in turn updates the gui), and a coll...

How do I store files or file paths in a java application?

I apologize if this is a really beginner question, but I have not worked with Java in several years. In my application, I need to keep up with a list of files (most, if not all, are txt files). I need to be able to add to this list, remove file paths from the list, and eventually read the contents of the files (though not when the file...

Simple database-like collection class in Java.

The problem: Maintain a bidirectional many-to-one relationship among java objects. Something like the Google/Commons Collections bidi maps, but I want to allow duplicate values on the forward side, and have sets of the forward keys as the reverse side values. Used something like this: // maintaining disjoint areas on a gameboard. Locat...

Efficient data structure for comparing items with most common attributes

I need a suggestion for an efficient data structure for the following problem. I have two lists of students (male and female) with their respective classes (sorted by date) they have already taken. The list is already alphabetized with their last name, first name. A user will give a student name, ie. student X, and what the program nee...

Comparing and updating array values in Python

I'm developing a Sirius XM radio desktop player in Python, in which I want the ability to display a table of all the channels and what is currently playing on each of them. This channel data is obtained from their website as a JSON string. I'm looking for the best data structure that would allow the cleanest way to compare and update t...

What is the best datastructure for a small and simple cache.

I often need relatively small (<10000 entries <1kb) caches for speeding up calculations. My usual code looks like this: cache = {} def calculate_caches(parms): if parms not in cache: cache[parms] = calculate(parms) return cache[parms] Works fine but for longer running processes I'm afraid of memory leaks. So I often im...

kCFNumberFormatterScientificStyle and kCFNumberFormatterDecimalStyle hybrid? - iphone / objective-c

in objective-c or iphone development has anyone ever done dynamic number formatting - something along the lines of "use kCFNumberFormatterDecimalStyle until the number gets too big, then use kCFNumberFormatterScientificStyle instead?" i want to display a number with some sort of hybrid between the two, but i'm having a little trouble wi...

SQL 2008 data types - Which ones to use?

Hi I'm using SQL Express 2008 edition. I've planned my database tables/relationships on a piece of paper and was ready to begin. Unfortunately, when I clicked on data type for my pkID_Officer I was offered more than I expected, and therefore doubt has set in. Can anyone point me to a place where these dates types are explained and exa...