data-structures

What is the best way to store data on a TreeView Node?

The TreeView is a nice way to present a hierarchy to users, but imagine the following scenario with the hierarchy depicted below: Building 1 -Tenant 1 - Payment 1 - Payment 2 Building 2 -Tenant 1 - Payment 1 -Tenant 2 - Payment 1 - Payment 2 where you need to do an insert to a database when the user clicks on the Pa...

Creating a Maze class in C++ using 16bit unsigned int array?

I'm attempting to make a data structure to represent a Maze in C++. All the data I need to hold about the maze can be stored in 16 bit integers using bitwise operations (to represent each cell of the maze): 16 bit unsigned integer So, I figured a 2d array of 16bit integers and I'm good to go for my Maze data structure. I wanted to ke...

Judy array for managed languages

Judy array is fast data structure that may represent a sparse array or a set of values. Is there its implementation for managed languages such as C#? Thanks ...

Lock free stack and queue in C#

Does anyone know if there are any lock-free container libraries available for .NET ? Preferably something that is proven to work and faster than the Synchronized wrappers we have in .NET. I have found some articles on the .NET, but none of them specify any speed benchmarking, nor do they inspire much confidence in their reliability. T...

Pre RTree step: Divide a set of points into rectangular regions each containing one point...

Hi, given my current position (lat,long) I want to quickly find the nearest neighbor in a points of interest problem. Thus I intend to use an R-Tree database, which allows for quick lookup. However, first the database must be populated - of course. Therefore, I need to determine the rectangular regions that covers the area, where each re...

Documenting a data model

What is the best way to document a logical or conceptual data model. Whilst tools like Visio allow you to define entities, attributes and relationships they do not support the collection of other vital information about a model such as validation rules, entity life cycles data owners. They also aren't very useful for communicating the...

Most efficient collection for this kind of LILO?

I am programming a list of recent network messages communicated to/from a client. Basically I just want a list that stores up to X number of my message objects. Once the list reaches the desired size, the oldest (first) item in the list should be removed. The collection needs to maintain its order, and all I will need to do is iter...

What are the complicated data structures you should have heard of?

This is a derivative question, but I'm inquiring as to the data structures that you should at least be familiar with for their usefulness. These structures are too hard to implement without some expertise however. I would say a good boundary between the two is a heap -- you should be able to code a heap, but it would take you a day. N...

Where can I learn about basic data structure concepts?

I have learned about data structures a long time ago. I need to refresh my knowledge of basic topics in data structure for a job interview. Can anyone provide me with some resources or links about this topic? ...

Multi column primary key mapped to a Dictionary<>... aka Struct vs. Class

So I've been trying to figure out the most efficient way to pull off this trick: I have a two column primary key in the database (an int and a string) and I'm trying to make a cache (I like using dictionaries) and I need to have a way to reference the two values as a key to get the object out. The key is private struct PageNameOnSite ...

How do you deal with the "Many Names for 1 Person" problem?

One of the most common problems I run into when creating any information system is the fact that people go by so many different names. Someone named "Bill Smith" may go by "Will Smith","William Smith", "Smith, Will", etc... If say, I wanted to write an application to link blog posts to authors, I would have to account for all those name...

Data structure that always keeps n-best elements

I need a data structure that always holds the n largest items inserted so far (in no particular order). So, if n is 3, we could have the following session where I insert a few numbers and the content of the container changes: [] // now insert 1 [1] // now insert 0 [1,0] // now insert 4 [1,0,4] // now insert 3 [1,4,3] // now insert 0 ...

How To Make a Tetris Clone?

I am working on coding a Tetris clone in XNA C# and am unsure of the best way to approach the data structure side of the game on a high level. I am totally fine with the collision detection, rotations, animation etc. What I need to know the best way to do the storing of "dropped blocks" - ie blocks that are no longer under tha player's ...

CPython internal structures

GAE has various limitations, one of which is size of biggest allocatable block of memory amounting to 1Mb (now 10 times more, but that doesn't change the question). The limitation means that one cannot put more then some number of items in list() as CPython would try to allocate contiguous memory block for element pointers. Having huge l...

C# .NET single-user database options

I'm going to be writing a Windows application using the .NET framework and C#. The application will need to store relational data which will be quieried, joined and processed. Previously I've done this using SQL Server, but that is a total overkill for the application I am now making. What's the simplest, easiest way to store relationa...

Best hybrid approach to a multi-dimensional array with strong typed indexing

I have what amounts to a multi-dimensional array. int[][][] MyValues; What I want is to access the indexes via a strongly typed equivelent, such as an enumeration. I'm aware that you can get the enumeration values from the Enum type, but it's a bit long winded for my tastes. I'd rather have a way to Strongly type the indexes. For e...

First Name Variations in a Database

I am trying to determine what the best way is to find variations of a first name in a database. For example, I search for Bill Smith. I would like it return "Bill Smith", obviously, but I would also like it to return "William Smith", or "Billy Smith", or even "Willy Smith". My initial thought was to build a first name hierarchy, but I...

What is the C# equivalent of the stl set?

I want to store some values in a balanced binary search tree using C#. I looked through the collections in the generics namespace and I haven't found an equivalent of the stl set. What generic collection can I use? (I don't want to store key/value pairs... just values.) ...

The best way to calculate the height in a binary search tree? (balancing an AVL-tree)

I'm looking for the best way to calculate a nodes balance in an AVL-tree. I thought I had it working, but after some heavy inserting/updating I can see that it's not working correct (at all). This is kind of a two-part question, the first part would be how to calculate the height of a sub-tree, I know the definition "The height of a no...

Is there an auto-resizing array/dynamic array implementation for C that comes with glibc?

Is there a dynamic array implementation in glibc or any of the standard Linux libraries for C? I want to be able to add to a list without worrying about its size. I know std::vector exists for C++, but I need the C equivalent. ...