data-structures

RoR: Tagging tags with other tags

I'm trying to prototype a system in Rails. Essentially, its an abstract relational data model that takes in user input to create nodes of information. Each node can have meta-information associated with it, so some nodes may have CreateDate and DueDate while others may have StartDate, DueDate and PersonResponsible. In this way we're simp...

c# serialized data

I have been using BinaryFormatter to serialise data to disk but it doesn't seem very scalable. I've created a 200Mb data file but am unable to read it back in (End of Stream encountered before parsing was completed). It tries for about 30 minutes to deserialise and then gives up. This is on a fairly decent quad-cpu box with 8Gb RAM. I'm...

mysql query question.

Hello I have a table with articles and the articles have a column category. The categories are filled like 1,4,6,8 How can i check if there is a product which has in it for example category 5 I tried something like select * from article where category in(5); But that doesn't work. If I use like than i will have a problem with for e...

What datatype/structure to store file list info?

I have an application that searches files on the computer (configurable path, type etc). Currently it adds information to a database as soon as a matching file is found. Rather than that I want to hold the information in memory for further manipulation before inserting to database. The list may contain a lot of items. I consider performa...

Why should hash functions use a prime number modulus?

A long time ago, I bought a data structures book off the bargain table for $1.25. In it, the explanation for a hashing function said that it should ultimately mod by a prime number because of "the nature of math". What do you expect from a $1.25 book? Anyway, I've had years to think about the nature of math, and still can't figure it ...

Fastest way to retrieve/store millions of small binary objects

Hi everyone, I am looking for a fast (as in huge performance, not quick fix) solution for persisting and retrieving tens of millions of small (around 1k) binary objects. Each object should have a unique ID for retrieval (preferably, a GUID or SHA). Additional requirements is that it should be usable from .NET and it shouldn't require ad...

What is com.apple.FinderInfo in `ls -l@` at Home?

I run ~ master $ ls -l@ I get total 3 drwx------+ 41 Masi staff 1.4K Jul 18 03:20 Downloads drwxr-xr-x@ 18 Masi staff 612B Jul 14 10:41 Dropbox com.apple.FinderInfo 32B drwx------+ 54 Masi staff 1.8K Jul 4 20:35 Library com.apple.FinderInfo seems to be some data-structure. ls' option @ should display only ...

Class Dictionary in java (data structure)

How to use Class Dictionary in java ? ...

Patterns/Principles for thread-safe queues and "master/worker" program in Java

I have a problem which I believe is the classic master/worker pattern, and I'm seeking advice on implementation. Here's what I currently am thinking about the problem: There's a global "queue" of some sort, and it is a central place where "the work to be done" is kept. Presumably this queue will be managed by a kind of "master" object. ...

how to interpret the windows registry 'ShellState' value

In the windows registry, under the key [HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer], there is a REG_BINARY variable called ShellState, 44 bytes in length. It looks suspiciously like a set of bit flags, but maybe there's some kind of struct present, really no way to tell from looking at it. Anyway, does anyone...

Definition of C# data structures and algorithms

This may be a silly question (with MSDN and all), but maybe some of you will be able to help me sift through amazing amounts of information. I need to know the specifics of the implementations of common data structures and algorithms in C#. That is, for example, I need to know, say, how Linked Lists are handled and represented, how the...

Best way to implement multiple levels within Objective-C roguelike?

I'm working on a roguelike using Objective-C/Cocoa to learn more. I've gotten most of the basic functionality out of the way, but I still have one problem I've been trying to figure out. Here's a breakdown of the process: First, the map is loaded: NSString* mapPath = [[NSBundle mainBundle] pathForResource:mapFileName ofType:mapFileTy...

Best data structure for search?

I have a list with items where each have number of properties (A, B, C, D) which I would like to filter using template containing same attributes (A, B, C, D). When I use a template I would like to filter all items matching this template. The match is assumed if item is equal to template or is smaller subsequence of it (0 match any item)...

lists in structs in F# ?

Hi I'm very new to F# and I'm trying to make a struct for storing polygons, and it has to contain a list of coordinates: type Polygon = struct val Coords : list new(list_of_Coords) = { Coords = list_of_Coords } end but Visual studio says "The type 'Microsoft.FSharp.Collections.list<_>' expects 1 type argument(...

Multi-key dictionaries (of another kind) in C#?

Building on this question, is there a simple solution for having a multi-key dictionary where either key individually can be used to identify the value? ie. MultikeyDictionary<TKey1, TKey2, TValue> foo; foo.Add(key1, key2, value); myValue = foo[key1]; // value == myValue foo.Remove(key2); myValue = foo[key1]; // invalid, Exception or n...

What is the best data structure for tree-like data of fixed depth in C#?

What is the optimal (easy to maintain, reasonably fast, robust) implementation of tree-like data structure with three levels? I would like to use Dictionary or SortedDictionary, because all values (nodes have unique key). The first level is supposed to have about 300 items, every of these zero to tens (hardly more than 100, usually less...

Library for the Basic Data Structures, such as Queue, in C

Post related to the question here. Problem: to find the right data structure for the queue: #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <time.h> int m...

What is the best data structure (container) for fast element insertion/deletion by index?

What is the best data structure (container) for fast element insertion/deletion by index? ...

Sorting two-way cell connections with priority

I have a two dimensional grid of cells. In this simulation, cells may request to switch position with another cell. The request also has a priority. The problem is that Im having a hard time coming up with a good way to structure this. If A wants to switch with B, and B also wants to switch with A, they currently can be switched and swi...

Struct for depth-curves in sea-maps

I'm trying to make a struct in F# for representing depth curves in a sea map. It has to contain a list of coordinates and a float telling what depth is represented (eg. "4.5 meters"). I have made it this way: type Coord = struct val X : float val Y : float new(x,y) = { X = x ; Y = y } end type DepthCurve...