data-structures

Querying Java Data Structures

Is there any way to perform SQL Like Queries or Filtering on Java Data Structures? I want to filter objects in an ArrayList and a HashMap by fields of the objects contained within. ...

Anyone know anything about OLAP Internals?

I know a bit about database internals. I've actually implemented a small, simple relational database engine before, using ISAM structures on disk and BTree indexes and all that sort of thing. It was fun, and very educational. I know that I'm much more cognizant about carefully designing database schemas and writing queries now that I kno...

Why do priority queues mostly use 0 as the most important priority?

Why are most priority/heap queues implemented as 0 being the highest priority? I'm assuming I'm missing out some key mathematical principle. As I was implementing my own priority queue recently it seemed easier to write the insert function if priority went up with the integer value, but apparently people smarter than me think it should g...

Data Structures in ORMs

Hi, How do you map rudimentary data structures (e.g. Tree, Dictionary) in an ORM such as NHibernate. ...

Message queue that delivers delayed messages and checks for uniqness

I have an online service that receives incoming events (few every second). Service needs to process a job when there were no events for 30 seconds or more. Service is distributed across several PCs and uses Amazon webservices (SQS and SimpleDB) as a backbone. I understand how can I schedule a job when there IS an incoming event (just pu...

Variable Dumping in C++

Hi guys, Is it possible to do a 'dump' on complex structures or even arrays in C++, in order to visually be able to check out what they've got inside them? I'm thinking of something similar to print_r() or var_dump() in PHP. Cheers, -Fin ...

C# Data Structures Question (Which collection to use?)

I need to implement a large collection of Widget objects, each of which contain a unique file path string ("FilePath"). I need to be able to do the following: Retrieve a Widget object quickly given the file path Change the file path of a Widget without creating a new object (multiple other objects may contain references to a single Wi...

What is wrong with Cursors ?

Hi, SQL Server developers consider Cursors a bad practise , except under some circumstances. They believe that Cursors do not use the SQL engine optimally since it is a procedural construct and defeats the Set based concept of RDBMS. However, Oracle developers do not seem to recommend against Cursors. Oracle's DML statements themselve...

C++ Implementation of a Binary Heap

I need a min-heap implemented as a binary tree. Really fast access to the minimum node and insertion sort. Is there a good implementation in stl or boost that anyone can point me too? ...

Django models - how to filter out duplicate values by PK after the fact?

I build a list of Django model objects by making several queries. Then I want to remove any duplicates, (all of these objects are of the same type with an auto_increment int PK), but I can't use set() because they aren't hashable. Is there a quick and easy way to do this? I'm considering using a dict instead of a list with the id as th...

An array of unknown size holding items with variable numbers of values/properties

I'm using a datatable where for each row I want to store some 3 or 4 fields, the fields are of different types, best case number of fields is 3, and I want to note the row_index (of the row in the datatable) as I need it. So like this I want to store the values (for the fields) for all the rows in the datatable. Please give me an examp...

Is the normal union/find algorithm thread safe without any extra work?

The standard union/find or Disjoint-set data structure has very good running times (effectively O(1)) for single threaded cases. However what is it's validity/performance under multi-threaded cases? I think that it is totally valid even without locking or any atomic operations aside from atomic pointer sized writes. Does anyone see any ...

When would I want to use a heap?

Besides the obvious answer of a Priority Queue, when would a heap be useful in my programming adventures? ...

Multiple Tuple to Two-Pair Tuple in Python?

What is the nicest way of splitting this: tuple = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') into this: tuples = [('a', 'b'), ('c', 'd'), ('e', 'f'), ('g', 'h')] Assuming that the input always has an even number of values. ...

Most efficient data structure to represent threaded comments in Java?

I want to represent threaded comments in Java. This would look similar to the way comments are threaded on reddit.com hello hello hello hello hello hello hello As in the example above, responses are nested in the HTML with appropriate indentation to reflect their relationship to prior comments. What would b...

iPhone / Objective C nested C structures

Hi, Can someone confirm that nested C structures are NOT allowed in objective C. And by nested structs, I mean the following; struct Tex2D { GLfloat u; GLfloat v; }; // quad uv cords struct TexQuad { Tex2D uv[4]; }; I seem to have all kinds of problems compiling this. It's difficult to find any documentation on this as ...

iPhone Development: What kind of data structures are available?

This is a very newbie questions, but does the iPhone API provide any data structures to work with (i.e. linked list, hash map, etc.)? ...

What Java Data Structure/Solution would best fit these requirements?

I need a java data structure/solution that meets these requirements. What best fits these? 1) Object's insertion order must be kept 2) Object's must be unique (These are database objects that are uniquely identified by a UUID). 3) If a newer object with the same ID is added, the older version of the object should be over-written/r...

save stack in arraylist

I want to know how to save stack in array list? ...

Sorting a linked list

I have written a basic linked list class in C#. It has a Node object, which (obviously) represents every node in the list. The code does not use IEnumerable, however, I can implement a sorting function? The language I am using is C#. Is there an example of this in C#? I am working from this sample: http://www.c-sharpcorner.com/UploadFi...