collections

Magento Collection Join Between Different Modules

I've been working on a custom module that has a backend for admin. Until now it has been working perfectly, just like the customer modules do, but now I'm stuck with this. My custom table saves the customer ID and I can show the customer name in every row of the grid. So far I'm able to show the ID, I know that I should prepare the colle...

C#/.NET/WPF: Obtaining subsets from LINQ, rather than the IEnumerable

I have some trivial code that looks like this: SortedDictionary<String, long> d = new SortedDictionary<String, long>(); // d is then populated with an expensive time-consuming process ListBox lb = new ListBox(); lb.ItemsSource = d; // THIS WORKS GREAT Now what I'd like to do is dynamically show a ...

NHibernate INotifyPropertyChanged Collection

I am just wondering what is the best way of getting INotifyPropertyChanged in my NHibernate Domain Objects' Collections? ...

Thread-safe HashSet with Guava Collections

Hello everybody. Like the title says, i would like to get a thread-safe HashSet using Guava Collections. Can you help me? Thanks! ...

Bind a Silverlight TabControl to a Collection

I have a Collection of Model-objects in my ViewModel. I would like to be able to bind a TabControl to these and use a DataTemplate to extract the information from the Model-objects. When I try to do this I get the errormessage: Unable to cast object of type Model to object of type TabItem. After spending some time looking for a solution ...

Is it possible to have a property that is IEnumerable<T>?

I have a class that's IEnumerable<T> where I want to have different properties that provides a filtered IEnumerable<T> access. So for instance: class Shape ShapeType = Box/Sphere/Pyramid class ShapeCollection : IEnumerable<Shape> { public IEnumerable<Shape> OnlyBox { foreach(var s in this) { if (s.Sha...

Adaptive Maps in Scala (or Java) Preserving Insertion Order

I would like to find and reuse (if possible) a map implementation which has the following attributes: While the number of entries is small, say < 32, underlying storage should be done in an array like this [key0, val0, key1, val1, ...] This storage scheme avoids many small Entry objects and provides for extremely fast look ups (even th...

Is it possible to write a recursive IEnumerable<T>

I have a class like: class Spline int ChildrenCount; Spline GetChild (int index) class SplineCollection : IEnumerable<Spline> Spline Master Is it possible to write a recursive IEnumerable for the SplineCollection where it will return all the children one by one? EDIT: So Master is the root Box, and the hierarchy of its c...

At what level is a given element in a Java TreeSet?

Does anybody know a fast way to detect at what level a given element is in a TreeSet? By level, I mean the depth of this element in the tree, i.e. the number of its ancestors. Background. I use Java's TreeSet class to store my elements. To compare two elements I need to compute some auxiliary information about them. I cannot store this ...

Collection with 10 elements (only)

Hi, I would like to make a score list with only 10 elements. Basically, simple collection which adds the value. If new value is higher than other one it adds one and last one get out. (everyone knows how it looks like :) ) Secondly, I need a list of 5 lastest values that have been changed, something like history panel. All in all, both...

How can I inherit from ArrayList<MyClass>?

I want to inherit from some kind of array/vector/list class so that I can add just one extra specialized method to it.... something like this: public class SpacesArray : ArrayList<Space> { public Space this[Color c, int i] { get { return this[c == Color.White ? i : this.Count - i - 1]; } ...

sorting collections with string elements in java

I have a collections...i wrote code to sort values using my own comparator my comparator code is private static class MatchComparator implements Comparator<xmlparse> { @Override public int compare(xmlparse object1, xmlparse object2) { String match1 = object1.getMatchId(); String match2 = object2.getMatchId(); ...

how hasnext() works in collection in java

program: public class SortedSet1 { public static void main(String[] args) { List ac= new ArrayList(); c.add(ac); ac.add(0,"hai"); ac.add(1,"hw"); ac.add(2,"ai"); ac.add(3,"hi"); ac.add("hai"); Collections.sort(ac); Iterator it=ac.iterator(); k=0; while(it.hasNext()) { Sy...

The best collection for holding a million items?

I would like to ask one interested (for me) question. What collection is the best by criteria performance if collection contains a lot of items (more than 1 million). By example, I create simple List(10000000) collection and try to add about 500000 different items. First 30000 items will be added in 10 seconds after running, but collec...

Sort and optimize Java Vector with custom objects

I have to optimize Java Vector with "class Row_i" - objects (see below), which describes two series(A and B) of number ranges (startPos - endPos) are equal in every row. This vector has to be sorted and optimized. Group/Sort Criterias: 1 - Row grouping by id_A, 2 - Row grouping by id_B, 3 - Row grouping by startPosA, 4 - Row grouping...

What does Collection.Contains() use to check for existing objects?

I have a strongly typed list of custom objects, MyObject, which has a property Id along with some other properties. Let's say that the Id of a MyObject defines it as unique and I want to check if my collection doesn't already have a MyObject object that has an Id of 1 before I add my new MyObject to the collection. I want to use if(!Lis...

Java vector help

Hi, I have just started the Java. Please let me know what this statement says class ABC{ transient Vector<int> temp[]; ABC(int max) { this.temp = new Vector [max]; } Is it creating a vector of int which size is max? I am C++ person. ...

A dictionary with multiple entries with the same key - C#

I need a Dictionary like object that can store multiple entries with the same key. Is this avaliable as a standard collection, or do I need to roll my own? To clarify, I want to be able to do something like this: var dict = new Dictionary<int, String>(); dict.Add(1, "first"); dict.Add(1, "second"); foreach(string x in dict[1]) { ...

Convert an array of objects to a dictionary of objects

i have an array of events: IEnumerable<CalendarEvent> events i want to convert this to a dictionary so i tried this: Dictionary<string, CalendarEvent> dict = events.ToDictionary(r => r.Date.ToString("MMM dd, yyyy")); the issue is that i have multiple events on a single date so i need a way to convert this to a Dictionary<string...

Shorthand declaration of long generic collection types.

I have looked at a lot of example c# generic code and remember seeing a syntactic declaration trick that created an alternative shorthand type for a long generic dictionary type. Mixing C# and C++ it was something like: typedef MyIndex as Dictionary< MyKey, MyClass>; This then allowed the following usage: class Foo { MyIndex _cla...