data-structures

Type-safe generic data structures in plain-old C?

I have done far more C++ programming than "plain old C" programming. One thing I sorely miss when programming in plain C is type-safe generic data structures, which are provided in C++ via templates. For sake of concreteness, consider a generic singly linked list. In C++, it is a simple matter to define your own template class, and th...

How to fit a custom graph to the boost graph library template?

I'm rusty on C++ templates and I'm using the boost graph library (a fatal combination). I've searched the web and can't find any direct instructions on how to take a custom graph structure and fit enough of it to BGL (boost graph library) that I can use boosts graph traversing algorithms. Anyone familiar enough with the library to help m...

String representations: improvements over ropes?

I want a representation for strings with fast concatenation and editing operations. I have read the paper "Ropes: an Alternative to Strings", but have there been any significant improvements in this area since 1995? EDIT: One possibility I've considered before is using a 2-3 finger tree with strings as leaves, but I have not done a deta...

List of generic algorithms and data structures

As part of a library project, I want to include a plethora of generic algorithms and data structures. This includes algorithms for searching and sorting, data structures like linked lists and binary trees, path-finding algorithms like A*... the works. Basically, any generic algorithm or data structure you can think of that you think mig...

java: sparse bit vector

Are there any well-known libraries in Java for sparse bit vectors? (And are there guidelines for how sparse is useful to use them vs. java.util.BitSet?) ...

How to implement a simple queue properly?

The current Go library doesn't provide the queue container. To implement a simple queue, I use circle array as the underlying data structure. It follows algorithms mentioned in TAOCP: Insert Y into queue X: X[R]<-Y; R<-(R+1)%M; if R=F then OVERFLOW. Delete Y from queue X: if F=R then UNDERFLOW; Y<-X[F]; F<-(F+1) % M. F: Front, R: Rear, ...

what else data/math structure describing causality except graph

I am trying to find some data structures/ math systems to represent causal relationships which are different graph, or Bayesian Network. Any idea? ...

Random Pairings that don't Repeat

This little project / problem came out of left field for me. Hoping someone can help me here. I have some rough ideas but I am sure (or at least I hope) a simple, fairly efficient solution exists. Thanks in advance.... pseudo code is fine. I generally work in .NET / C# if that sheds any light on your solution. Given: A pool of n indiv...

Java datastructure to map multiple keys to the same value

In Java I'm looking for a way to map multiple keys to the same value. Let's say I have the numbers 0-9 as keys, and "x", "y" and "z" as values as follows: 0->y 1->y 2->y 3->x 4->x 5->y 6->z 7->y 8->z 9->z now x,y and z are really long strings, and I have millions of keys so I can't afford to store the strings multiple times. How would...

Small questions on data structure

Hi, I'm trying to search the parent of a node with Kruskal's algorithm. My program works just fine, but I think I have heard of a method to improve the speed of the algorithm by reconstructing the tree while searching for the parent node and connecting it to the parent node. I'm pretty sure that I've heard of this somewhere, maybe in a l...

Java and Different Types of Stacks

Currently the only stack I know anything about is Vector, I normally use this in place of an array but I understand that there is other types of stacks and they all suit different jobs. The project I am currently working on requires me to be inserting objects in a certain position inside a stack, not always the front of the stack and I ...

How To Add Reference a Webservice public Struct in App

Originally posted on: http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_21355401.html I have a solution containing two projects: a webservice project and a web app project which has a web reference to the webservice project (the web app project is simply a test case). My webservice project includes a class file containi...

writting a non recursive Randomized-Select algorithm

Hi I have written this code for having a non recursive Randomize-select algorithm !would you help me that is this correct also this is not my homework I want to make my ability to write such an algorithm.thanks Algorithm Random-Select ( arr,1,n,i): If (n=1) then return arr[1] randomPivot<-- Random-Partition(arr,1,n) k<--randomPi...

Using R to open grib files

I am using R to work with meteorological data. I proceed in two steps: 1- convert grib to netcdf using the commande line function ncl_convert2nc from ncar command language 2- use package ncdf in R to import the netcdf data. I still have one problem: 2- For some particular grib files, the convertion with ncar tool does not work. Is ...

How to get results efficiently out of an Octree/Quadtree?

I am working on a piece of 3D software that has sometimes has to perform intersections between massive numbers of curves (sometimes ~100,000). The most natural way to do this is to do an N^2 bounding box check, and then those curves whose bounding boxes overlap get intersected. I heard good things about octrees, so I decided to try impl...

Item in multiple lists

So I have some legacy code which I would love to use more modern techniques. But I fear that given the way that things are designed, it is a non-option. The core issue is that often a node is in more than one list at a time. Something like this: struct T { T *next_1; T *prev_1; T *next_2; T *prev_2; int value; }; t...

Ref to map vs. map to refs vs. multiple refs

I'm working on a GUI application in Swing+Clojure that requires various mutable pieces of data (e.g. scroll position, user data, filename, selected tool options etc.). I can see at least three different ways of handling this set of data: Create a ref to a map of all the data: (def data (ref { :filename "filename.xml" :scroll ...

Anyone familiar with mp4 data structure?

Where in the mp4 file structure is the duration of it? ...

represent binary search trees in python

how do i represent binary search trees in python? ...

Strategy to structure a search index in a relational database

I am interested in suggestions for building an efficient and robust structure for indexing products in a new database I am building (i'm using MySql) When a product is entered through the form there are three parts I am interested in indexing for searching purposes. The product title The product description Tags The most important ...