data-structures

Any advantages of binding a list of objects to a grid instead of to a datatable? (.NET)

I have a business object let's say a Customer. I have a DAL method which brings back a datatable of customers. I have a UI which has a grid which will display a list of customers. My question is.. is it OK to bind the grid to the datatable, which means the UI will have a reference to System.Data or should the datatable be converted firs...

What is better in Perl: an array of hash references or list of "flat" hashes?

I cannot decide which approach is more (1) idiomatic Perl, (2) efficient, or (3) "clear". Let me explain by code. First, I can do sub something { ... $ref->{size} = 10; $ref->{name} = "Foo"; $ref->{volume} = 100; push (@references, $ref); ... return @references; } or, I can do sub something { ... push (@names, ...

Finding edge in weighted graph

I have a graph with four nodes, each node represents a position and they are laid out like a two dimensional grid. Every node has a connection (an edge) to all (according to the position) adjacent nodes. Every edge also has a weight. Here are the nodes represented by A,B,C,D and the weight of the edges is indicated by the numbers: A ...

How to convert a Perl hash-of-hashes to a more flexible data structure?

In a quick-and-dirty Perl script, I have a data structure like this: $tax_revenue{YEAR}{STATE}{GOVLEV}{TAX} = integer The hash keys assume values like this: YEAR: 1900 .. 2000 STATE: AK, AL, ... WY GOVLEV: state, local TAX: type of tax (income, sales, etc.) In addition, the hash keys are unique. For example, no value for the TAX pa...

Multi-Resolution occupancy grid maps data structure

Where can i find an implementation of the Multi-Resolution occupancy grid map . its used in game engines and a lot in robotics and comes under spatial data structures? is there a c++ / java library ? ...

Is there a way to access the underlying container of STL container adaptors ?

Is there a standard way to access the underlying container of stack, queue, priority_queue ? I found a method called : _Get_container() in VS2008 implementation of stack and queue, but no one for priority_queue! I think it is not standard anyway. Also, I know it is a silly question! where can I find official documentation of the standa...

Why does many-to-many data structure require two additional tables?

This question is based on the thread. If we have one-to-many data structure, we need to have a "help-table" to store for instance phonenumbers for one person. Many person cannot have the same phonenumbers. I look forward for an explanation why we then need two "help-tables" between many-to-many relations. An example of this is a questi...

Recommended data structure for a Data Access layer

I am building a DataAccess layer to a DB, what data structure is recommended to use to pass and return a collection? ...

What are the benefits of not using cPickle to create a persistent storage for data?

I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module? ...

Efficient TableModel implementation

My TableModel implementations typically sit on an ArrayList to allow for efficient random access performance. However, ArrayList's remove(int) implementation looks fairly inefficient as it involves making a System.arrayCopy(...) call to shift all subsequent elements back by 1. What approaches to people take to implementing TableModels?...

How to store tables in C# - What kind of data structure should I use?

Here is how it looks generally: I get values from an outside device and I have to store a timestamp with them. Somehow I want to store the info in an efficient way to make my life easier when it comes to processing all the stuff. As a simple solution I have created a class which stores one row: public class X { public DateTime time...

Multidimensional array manipulation - Java

I have a series of arrays that i draw data from and ultimately lead to a final array that holds the information i want. The final array is 2-dimensional, being comprised of a large number of single dimensional arrays, each holding up to 3 entries. int[][] realOcc = new int[result.length][3]; The way the array holds data is as follows:...

(Ruby On Rails) How to design the structure of functions to create the various documents ?

I want to build a website which can generate a specific employments contracts depends on the users(would be employer or HR manager) inputs and type of the employment. But now, I found it is damn hard to create pages and pages just because they have the different format, e.g the full-time employment contract will not have the sections on...

How to write a function that gets a linked list of any node type and frees the memory used by it?

I'm sure some of you already experienced it. I have two linked lists of different types and I have two distinct functions that free the memory used by them. Those two functions are identical except for one thing. Generally a function that frees a list would looks like this: void free_list(T *p) { T *next; /* here */ while (p...

Does it make sense to implement iterators for containers which has no obvious end - e.g. trees?

I`m writing binary search tree template for two reasons - learning C++ and learning most common algorithms and data structures. So, here is the question - as long as I want to implement iterators, it seems to me that there is no strict definition for where tree ends. What are your suggestions? How do I do this? ...

How do you handle the fetchxml result data?

I have avoided working with fetchxml as I have been unsure the best way to handle the result data after calling crmService.Fetch(fetchXml). In a couple of situations, I have used an XDocument with LINQ to retrieve the data from this data structure, such as: XDocument resultset = XDocument.Parse(_service.Fetch(fetchXml)); if (resultset.R...

Data structure for repeatedly splitting a string into smaller parts

Hello, I'm trying to write a function that repeatedly matches regexp patterns against an input string. The function should take pattern 1 match it against the input string and split it into parts of matching and non-matching segments. Pattern 2 would subsequently be used on those non-matching segments, until all input patterns are used...

Which data structure best represents this data?

Is this a list of lists or just a bunch of trees(forest)? ...

Efficient Hashmap Use

What is the more efficient approach for using hashmaps? A) Use multiple smaller hashmaps, or B) store all objects in one giant hashmap? (Assume that the hashing algorithm for the keys is fairly efficient, resulting in few collisions) CLARIFICATION: Option B implies segregation by primary key -- i.e. no additional lookup is necess...

Tracking the progress of a recursive method

I'm writing an application that makes use of a tree structure, so of course I have some recursive methods that will iterate down every node of the tree and do something. The problem is sometimes these take a while, and I'd rather show a progress bar of some sort to the user rather then the program stop responding for a period of time. I...