collections

WPF - Can't display ObservableCollection in a window

I have an ObservableCollection that I can't seem to get to display in a window. Here is the code: The View Model: public class QueryParamsVM : DependencyObject { public string Query { get; set; } public QueryParamsVM() { Parameters = new ObservableCollection<StringPair>(); } public ObservableCollection<St...

Advice for efficient blocking queries

I would like to store tuples objects in a concurent java collection and then have an efficient, blocking query method that returns the first element matching a pattern. If no such element is available, it would block until such element is present. For instance if I have a class: public class Pair { public final String first; public...

Can a collection in NHibernate be mapped as read-only?

I have a mapping defined where a parent object has a collection of child objects. In my design, I'd like to be able to delete the child objects without having to remove them from the collection on the parent object and re-saving the parent object. However, when I try this, I get the "deleted object would be re-created on save" error. ...

initialize java HashSet values by construction

Hello, I need to create a Set with initial values. Set<String> h = new HashSet<String>(); h.add("a"); h.add("b"); Is there a way to do it in one command? Thanks ...

How to extend a TFieldDef in easy and safe way?

Hi guys. I need an advice in problem with TFieldDef. I need to add one additional string property to the TFieldDef called Description. I want to see that property when I iterate over TFieldDefs collection. How to do this in Delphi 2007? Thanks for your time. ...

How to efficiently (performance) remove many items from List in Java?

I have quite large List named items (>= 1,000,000 items) and some condition denoted by <cond> that selects items to be deleted and <cond> is true for many (maybe half) of items on my list. My goal is to efficiently remove items selected by <cond> and retain all other items, source list may be modified, new list may be created - best way...

What is/are the Python equivalent(s) to the Java Collections Framework?

The Java Collections Framework is like the C++ Standard Template Library: "a unified architecture for representing and manipulating collections (objects that group multiple elements into a single unit)." http://java.sun.com/docs/books/tutorial/collections/intro/index.html ...

What collection to use instead of 2D array in Java?

I want to use a collection in place of 2D array so that I don't need to give its size at the time of declaration and I can add as many elements as I want dynamically. ...

How should exceptions be handled when processing a collection?

Let's say you have a function (X) that takes a single object and does some work with it. It can fail in some way: function X(obj) throws SomeException And I have a collection of these objects, and want to run X on all of them. So I wrap that up in its own function: function Y(objs) foreach obj in objs X(obj) end end What is...

Is there the equivent of a Java Set in php?

Is there the equivalent of a Java Set in php? (meaning a collection that can't contain the same element twice) ...

Filter Magento Product Collection for Products with Images

I have a product collection that I am getting from a configurable product, and I want to filter that collection to only include products that have images attached to them. How do I go about this? Code looks something like this: $configurableProduct = $this->getConfigurableProduct(); $childProducts = $configurableProduct->getTypeInstanc...

What is the fastest way to count the unique elements in a list of billion elements?

My problem is not usual. Let's imagine few billions of strings. Strings are usually less then 15 characters. In this list I need to find out the number of the unique elements. First of all, what object should I use? You shouldn't forget if I add a new element I have to check if it is already existing in the list. It is not a problem in ...

How do you interate over a Collection<T> and modify its items without ConcurrentModificationException?

I need to do something like this... Collection<T> myCollection; ///assume it is initialized and filled for(Iterator<?> index = myCollection.iterator(); index.hasNext();) { Object item = index.next(); myCollection.remove(item); } Obviously this throws ConcurrentModificationException... So I have tried this but doesn't does s...

Adding a photo collection using the flickr API

Hi, Is it possible to create a photo collection using the flickr API? I haven't found any example code to achieve this, however you CAN do it on the flickr website, and i suppose flickr uses the API internally for their site? Dennis ...

Why is ReadOnlyObservableCollection.CollectionChanged not public?

Why is ReadOnlyObservableCollection.CollectionChanged protected and not public (as the corresponding ObservableCollection.CollectionChanged is)? What is the use of a collection implementing INotifyCollectionChanged if I can't access the CollectionChanged event? ...

Custom Object collection Serialization

I'm attempting to Serialize my custom collection UserDataCollection, made out of UserData objects. I wondered when implementing Serialization, does the actual object (UserData) also need have the attribute [Serializable] and inherit from the ISerializable interface? I want to serialize each object (UserData) in the collection, all it's...

Is it possible to use Microsoft.VisualStudio.QualityTools.UnitTesting.CollectionAssert on an IEnumerable<T>?

I have a testing scenario where I want to check if two collections are equal. I have found the class Microsoft.VisualStudio.QualityTools.UnitTesting.CollectionAssert, but it only works on ICollection<T>. Since I'm testing a repository for Entity Framework, and thus need to compare IObjectSet<T>s, that won't do - IObjectSet<T> doesn't imp...

serialize each object in Object collection

I have this code for serializing my custom collection of UserData Objects. However the current property only represents the item currently being used in the collection, so it only serializes that one object. I want all the objects serialized in my collection, how would I go about that in the GetObjectData implementation of my Collectio...

How to iterate through google collections' Multimap<?, Object> ?

Before using google collections I had something similar to next code: private Set<A> aSet = ...; private Set<B> bSet = ...; public Foo getFoo (Map<?, List<Bar>> bars, Set<?> set) { for (Object item : set) { for (Bar bar : bars.get (item)) { //build foo; } } ... } and I was able to make calls like these:...

Collection was modified; enumeration operation might not execute.

hi all how r u i faced problem with datatable when i run to client it throw exception and mention the "in" in foreach. Collection was modified; enumeration operation might not execute. this is the code plz help: foreach (DataRow dr in stStatusTable.Rows) { if (Convert.ToInt32(dr["st_id"]) == stStatus.st_id) { dr["st_id"...