data-structures

Why does my program read an extra structure?

Hi all. I'm making a small console-based rpg, to brush up on my programming skills. I am using structures to store character data. Things like their HP, Strength, perhaps Inventory down the road. One of the key things I need to be able to do is load and save characters. Which means reading and saving structures. Right now I'm just savi...

F# Immutable variable sized window data structure

I have below a description of a data structure I need and I want to implement it using immutable data structures. I'm trying to determine... is there an existing data structure out there that will support what I'm trying to do here or do I need to create one--and if I need to create it, what would be a good place to start (building block...

HashMap implementation of DataSource interface : nextRow() method ???

Hi, I would like to implement a DataSource interface (in Java) which, among other things, allows you to aquire the nextRow() from the data. I initially just want to implement the data store via HashMaps, but it would be cool to abstract away from the underlying data structure, and provide an interface as mentioned. Does this sound like...

F# Efficiently removing n items from the end of a Set

I know I can remove the last element from a set: s.Remove(s.MaximumElement) But if I want to remove the n maximum elements... do I just execute the above n times, or is there a faster way to do that? To be clear, this is an obvious solution: let rec removeLastN (s : Set<'a>, num : int) : Set<'a> = match num with | 0 -> s ...

Binary Decision Diagram library for windows

After trying to get jinc compiled under windows and quickly running into hundreds of compiler errors I'm looking for a quality BDD library that will build for windows. Preferably in C or C++ but as long as I can bind to it I'm happy. ...

How to sort the list with duplicate keys?

I have a set of elements/keys which I'm reading from two different config files. So the keys may be same but with different values associated with each of them. I want to list them in the sorted order. What can I do ? I tried with SortedList class but it does not allow duplicate keys. How can I do it? e.g Lets say I have 3 elements wi...

What is an appropriate data structure or algorithm for producing an immutable concrete syntax tree in a functionally pure manner?

Given a LL(1) grammar what is an appropriate data structure or algorithm for producing an immutable concrete syntax tree in a functionally pure manner? Please feel free to write example code in whatever language you prefer. My Idea symbol : either a token or a node result : success or failure token : a lexical token from source text...

best way to import dataset into matlab and organize data into appropriate structure

Hi, I have a text file of 10001 lines, where first line contains the name of the attributes and the following lines contain values. The attribute types are mixed (strings and floats) and delimited by '\t'. Does anyone know what is the best way to import such text file into matlab and organize these data into appropriate structure for f...

Removing elements from a list containing specific characters

I want to remove all elements in a list which contains (or does not contain) a set of specific characters, however I'm running in to problems iterating over the list and removing elements as I go along. Two pretty much equal examples of this is given below. As you can see, if two elements which should be removed are directly following ea...

R - How to convert a factor to an integer\numeric in R without a loss of information

When I convert a factor to a numeric, the values change to rank values. R> m$obs [1] 0 0 1 1 1 1 3 3 3 3 3 3 3 9 9 9 9 9 9 9 9 9 11 11 12 13 13 13 13 13 13 13 14 Levels: 0 1 3 9 11 12 13 14 R> as.numeric(m$obs) [1] 1 1 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 6 7 7 7 7 7 7 7 8 I have to resort to paste() ...

data structure for transversal tree in PHP?

I don't have a background in CS or data structures. I want to make a PHP class that stores a modified preorder transversal tree, for manipulation and syncing with a database. Basically I need to store data like: +-------------+----------------------+-----+-----+ | category_id | name | lft | rgt | +-------------+-------...

Good data structure for euclidean 3d data queries?

Hi guys, What's a good way to store point cloud data so that it's optimal for an application that will do one of these two queries? Nearest (i.e. lowest euclidean distance) data point to (x,y,z) Get all the points inside a sphere with radius R around a point (x,y,z) The structure will only be filled once, but read many times. A lowi...

What datatype is this? is it wordpress specific ?

Hey can anyone tell me what datatype this is? it wont parse as i've stripped out sensitive data. Am I correct in thinking its json? a:7:{s:12:"competitions";a:893:{i:1;s:10:"Ersie";i:5;s:19:"General News"1510126584;s:0:"";i:1019;s:0:"";i:8284;s:0:"";i:191016;s:0:"";i:284;s:0:"";i:91019;s:0:"";i:81863;s:0:"";i:1563;s:0:"";i:7101...

choosing right data structure

Hi, I need to know What is the best data structure to use when transferring and storing large amounts of data across different COM objects in MFC application. (the data is usually large strings, xml files, images etc) Is there any memory issue if I use CList, CMap etc Thanks ...

Prim's MST algorithm in O(|V|^2)

Time complexity of Prim's MST algorithm is O(|V|^2) if you use adjacency matrix representation. I am trying to implement Prim's algorithm using adjacency matrix. I am using this as a reference. V = {1,2...,n} U = {1} T = NULL while V != U: /* Now this implementation means that I find lowest cost edge in O(n)....

Data Structure To Store Arbitrary Database Tables

Hello, I'd like to design a JVM data structure (Java/Scala) that can be used to represent and store the contents of arbitrary relational database tables. The data structure should be fast (not too gc-intensive, cache-friendly) and memory efficient, so larger tables can fit in RAM. One memory-efficient solution is to store each column ...

A huge data storage problem

Hey guys! I'm starting to design a new application that will be used by about 50000 devices. Each device generates about 1440 registries a day, this means that will be stored over 72 million of registries per day. This registries keep coming every minute, and I must be able to query this data by a Java application (J2EE). So it need to ...

Looping a RECORDSET

I have a webservice that returns me a recordset. The record set looks something like this. COUNTRYNAME STATEPROVINCE POPULATION CANADA ALBERTA 2.7 million CANADA NOVA SCOTIA 1.6 million UNITED STATES PENNSYLVANIA 4.5 million UNITED STATES NEW JERSEY 6.8 million This ...

All possible combinations of a list of a list

Hi I am in desperate need for some algorithm help when combining lists inside lists. Assuming that I have the following data structure: fields = [ ['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'], ['d1', 'd2', 'd3'] ] I am trying to write a generator (Python) that will yield each possi...

perl - help passing/looping in arguments from file or within a separate perl data structure

I have a while loop that reads in a single file: my %MyItems = (); while (my $line = <>) { chomp $line; if ($line =~ m/(.* $mon $day) \d{2}:\d{2}:\d{2} $year: ([^:]+):backup:/) { my $BckupDate="$1 $year"; my $BckupSet =$2; $MyItems{$BckupSet}->{'MyLogdate'} = $...