collections

What is the fastest way to sum a collection in Scala

I've tried different collections in Scala to sum it's elements and they are much slower than Java sums it's arrays (with for cycle). Is there a way for Scala to be as fast as Java arrays? I've heard that in scala 2.8 arrays will be same as in java, but they are much slower in practice ...

Is there a generic equivalent to ArrayIterator from Apache Commons Collections?

ArrayIterator is handy (although I don't need the reset functionality), but like the rest of the Commons Collections stuff, it doesn't use generics. I checked Google Collections, but I didn't see a close equivalent. Did I miss it? Is there another library of similar reputation and quality as the first two that provides such a thing? Than...

Java convert {String,String}[] to Map<String,String[]>

Given the class: public class CategoryValuePair { String category; String value; } And a method: public Map<String,List<String>> convert(CategoryValuePair[] values); Given that in values we can receive many entries with the same category, I want to convert these into a Map grouped on category. Is there a quick / eff...

How to automatically update UI when items are added to List<>

Wihtin my current project I have to add data items to a List<> object. I am using a list due to the fact that it is being derived from an external type and due to how it is being utilized by other applications I do not have the ability to request that the type be changed in the assembly from List to ObservableCollection. So as of right n...

Java - How to create new Entry (key ,value)

I'd like to create new item that similarly to Util.Map.Entry i.e. that will already contain the structure key,value The problem is that I can't use Map.Entry itself because apperently it's a read-only object that I can't instanciate new instance of it. Does anyone know how to create new generic key/value object? ...

Hibernate collection fetching optimally

I have the following structure Store Rebate RebateMetadata RebateCommission So, the relation is like this - Store -> Rebate is a one to many relation Rebate -> RebateMetadata is a one-to-one mapping Rebate -> RebateCommission is a one-to-one mapping My Query is to load all stores. And with it, load all Rebates ...

System.Collections Vs System.Collections.ObjectModel [.net]

There seem to be cetain collection classes in System.Collections.ObjectModel as well. What is the difference between the collections under these two namespaces and in which scenario should we use System.Collections.ObjectModel ? Thanks for your interest. ...

Concurrent Set Queue

Maybe this is a silly question, but I cannot seem to find an obvious answer. I need a concurrent FIFO queue that contains only unique values. Attempting to add a value that already exists in the queue simply ignores that value. Which, if not for the thread safety would be trivial. Is there a data structure in Java or maybe a code snipit...

convert java.util.Map[String, Object] to scala.collection.immutable.Map[String, Any]

How do I convert java.util.Map[String, Object] to scala.collection.immutable.Map[String, Any], so that all values in the original map (integers, booleans etc.) are converted to the right value to work well in Scala. ...

actionscript array with index and key

What would be the best way to create an array that can have an index and a key at the same time ? i mean something like this index | key | value 0 | "myItem" | "Some value" 1 | "anotherItem" | "Some other value" 2 | "blabla" | "Bla Bla" I know i can create a normal Array/Vector and then...

Display collections on my website using Flickr API

Hello everyone, I have been looking for a long time where I could find a php script using phpflickr class (or not) in order to display collections (titles, images or both) on my website. I can't find any. If anyone has idea... Thanks in advance. Regards, Pico ...

what is the best collection type to return in an API

i have always thought that returning Arrays were better than lists when having a public API but it seems now there are all these functions on lists that are available through LINQ, etc. Has the best practice changed here for returning collections of primitives or objects? for example: Order[] GetOrders(); List<Order> GetOrders(); IEnu...

How to avoid implementing INotifyPropertyChanged manually

Is there some way to avoid this. I have a lot of classes that are bound to DataGridViews and they are just simple collection of properties with default getter and setter. So these classes are very simple. Now I need to implement INotifyPropertyChanged interface for them which will increase the amount of code a lot. Is there any class tha...

Do we have sorting and searching function in .net

I was implementing linear search for search in a collection then i thought why not use binary search, for which i had to use sorting. Although I can implement them, but I would like to know where does they exists in .net itself. I hope it would be present in .Net. ...

Collections as decorators in C#

Hey there! We've been hit with a pretty "obvious" problem while designing a collections infrastructure: suppose you need to implement many (sub)types of collections. One of the aspects is storage-related: list, array etc, while the other is behavior-related: ordered, remove only, observable (the one that fires an event upon every change...

Collections as decorators: pseudo-code implementation proposal

Meanwhile waiting for the answer on the question I would like to discuss the possible implementation plan/details or in general even answer how hard would be to implement the following and which tools/techniques are necessary for that: (excerpt from the referred question): Suppose you need to implement many (sub)types of collecti...

java.util.TreeMap behavior question

The class docs state that Entrys cannot be modified via .setValue(...) but also caveat that put(...) works fine. Does that mean put(...) will work fine when iterating over the collection views like navigableKeySet() (i.e., not result in a ConcurrentModificationException), as long as no structural modifications (i.e., adding a new key) a...

incuding non data elements into a WPF databound combo box

I've been working with two different combo boxes within my solution ( Department and Name) these combo boxes are currently bound to a list collection that is being returned from an external service reference. Where I have a question is in that I need to insert other elements into the combo box other than what is being provided by the API...

How to select a partial object including a list with new() syntax in Hibernate

In my Hibernated system, I have a class Picture that has some simple data, a list of Installations and some (huge) binary data. The list of Installations is implemented with a join table, as it's a ManyToMany relation, and it's defined on the Installation side: @Entity public class Picture { @Id private long pictureId; private Str...

Help with rails collection_select [edited]

I have been trying to implement this jquery plugin to my app.I need help trying to output something like this <select name="user[university_id]" id="user_university_id" class="selectable"> <option value="1" title="uni1">Uni1</option> <option value="2" title="uni2">Uni2</option> </select> by using a rails helper...the problem i...