data-structures

How is the data stored in a textbox?

I was reading this paper "Ropes: an Alternative to Strings" about ropes [figure from the same paper] and I was wondering if that is the data structure used by today's browsers to implement textboxes or not. Do we use ropes or some other data structures for this? Are ropes used somewhere besides textboxes? The previous title of m...

Simple csv reader?

all, I started out with what i thought was going to be a pretty simple task. (convert a csv to "wiki" format) but im hitting a few snags that im having trouble working through I have 3 main problems 1) some of the cells contain \r\n ( so when reading line by line this treats each new line as a new cell 2) some of the rows contain "...

Reading an unsigned 24-bit integer from a C# stream

What is the best way to read an unsigned 24-bit integer from a C# stream using BinaryReader? So far I used something like this: private long ReadUInt24(this BinaryReader reader) { try { return Math.Abs((reader.ReadByte() & 0xFF) * 256 * 256 + (reader.ReadByte() & 0xFF) * 256 + (reader.ReadByte() & 0xFF)); } cat...

How to store different data types in one list? (C++)

I need to store a list of various properties of an object. Property consists of a name and data, which can be of any datatype. I know I can make a class "Property", and extend it with different PropertySubClasses which only differ with the datatype they are storing, but it does not feel right. class Property { Property(std::string...

Is a KD-Tree a unique ordering of a given data set?

Given a set of data points, a kdtree is created over them, but is this kdtree a unique one? ...

How to model data entities with multiple parents?

How would I model a relationship between multiple entities where one entity could be part of two separate, unrelated, hierarchies and each entity could be related to 1 or more other entities in a non-hierarchical fashion? I would like to do this in only 2 or 3 tables in the database. I currently have it modeled into two tables: Entit...

Best software (or other) solution for modeling existing complex MySQL schema

Hi Stack Overflow, What's a good solution for modeling an existing and very complicated MySQL schema. Preferably with the following features: completely visual drill down on click shows keys, indexes gives sample data per field* *as fields aren't always intuitively named Thanks! Emile ...

Grid of checkboxes represents a many-to-many db relationship; the best way to get from webform to database (not passing go, not collecting £200)

I am using jquery/jsp/java ejb3.0/sql server. The User interface requirement (a jsp page) is a grid of checkboxes, ~10 rows high and up to about ~30 rows wide (this varies), it represents a linker table for a many-to-many table relationship. The checkboxes will be populated from the database (if row present in linker table, checkbox ch...

Is there a nice Java object to hold a 2D grid of doubles?

Is there a data type that simply holds a 2D grid of doubles? Preferably in the JDK but I'm happy to use an open source 3rd party library like apache commons etc. I'm looking for a class, and/or complimentary helper classes, that allow methods like these: Grid g = new DoubleGrid(100, 100); double min = g.getMinValue(); double someCell...

Django strategy card game structure

Hey guys, I'm doing a multi-player text based card game for fun in Django where each card allows each player to make some standard actions (Draw more cards, get gold, get points etc.) and maybe some other abilities (Like destroy a card from an opponents hand, give an opponent minus points and many more). I have created a Card class: c...

Can R-Trees maintain z-order when using 2 dimensions?

I'm writing an implementation of an R-Tree based on Guttman's original paper. I was thinking about using an R-Tree for a program I'm writing that involves a lot of rectangles on the screen that can be moved/re-sized with the mouse. I want to efficiently only select rectangles that are in a particular rectangle and draw them (instead of...

Java Data Structure for string matching

I have a long list of arbitrary strings and I'd like to determine if my given string "ABADCAFE" starts with any of the strings in my list. Is there a library class somewhere that can do this for me reasonably efficiently ? (I suppose it's much like the state machine built by regex, but I don't think composing a regex is the way to go he...

Recommendations on books for multi-threaded data structures?

I need some recommendations of books/links that discuss design on multi-threaded data structures for an intermediate level C++ developer who knows STL/Boost and pthreads individually but would now like to blend these 2 knowledge streams. Any help appreciated. ...

Storing & Querying Heirarchical Data with Multiple Parent Nodes

I've been doing quite a bit of searching, but haven't been able to find many resources on the topic. My goal is to store scheduling data like you would find in a Gantt chart. So one example of storing the data might be: Task Id | Name | Duration 1 Task A 1 2 Task B 3 3 Task C 2 Task Id | Predecessors...

Data Structure that introduces data like a stack, and stores in buckets like a hashtable?

Hello! I need an algorithm that introduces data like a stack, so when I scan the structure I can read them in the same sequence as they were introduced, for sequential access. Also these values are stored in buckets, like a hashtable, so I can fragment the whole structure for disk storage and have fast random access. Is there an algorit...

Why No Cycles in Eric Lippert's Immutable Binary Tree?

I was just looking at Eric Lippert's simple implementation of an immutable binary tree, and I have a question about it. After showing the implementation, Eric states that Note that another nice feature of immutable data structures is that it is impossible to accidentally (or deliberately!) create a tree which contains a cycl...

What is the problem with this piece of C++ queue implementation?

Hi everyone! I'm trying to write a linked queue in C++, but I'm failing so far. I've created 2 files by now: my main.cpp and box.h. When trying to use my box, I receive the following message: Description Resource Path Location Type conversion from ‘Box*’ to non-scalar type ‘Box’ requested main.cpp /QueueApplicati...

Circular Linked List in C

Why exactly do we need a "Circular Linked List" (singly or doubly) data structure? What problem does it solve that is evident with simple Linked Lists (singly or doubly)? ...

Transforming character strings in R

Dear Stackers, I have to merge to data frames in R. The two data frames share a common id variable, the name of the subject. However, the names in one data frame are partly capitalized, while in the other they are in lower cases. Furthermore the names appear in reverse order. Here is a sample from the data frames: DataFrame1$Name: "Van...

JTable design to synchronize with back-end data-structure

I have a JTable which is loaded from a data-structure using table model.The data-structure is of the format NavigableMap<Float,NavigableMap<Float,Boolean>>.An example data is: Table Format: Range f1,v1 f2,v2 f3,v3 f4,v4 12.1-30.2 30,true 32,false 45,true 50,false 30.2-45.6 30,true 32.4,true 45,true 50.1,true The above data...