collections

I'm having problems understanding IQueryable<>

So I'm trying to understand IQueryable<>. A tutorial I'm reading suggests using it but not really sure why. The code simply returns some values using LINQ to SQL. I've done this plenty of times in the past, but not using IQueriable<> Why use it with my functions that return more than 1 value? Here's my code: public IQueryable<Items...

Is returning List<T> from method differ in performance from returning Collection<T> ?

We have a web project that contain its business methods in a class library project called "Bll.dll" some methods of Bll.dll return List<> ... from a source - that i don't remember now - told that returning Collection<> is better than returning List<> Is it a valid ? Note that i don't make any process on values returned from BLL methods ...

Appropriate use of friend? Container class designed to manipulate objects of specific type

Lets say you have a FooManager made to manage multiple objects of type Foo. The FooManager needs to see some parts of its Foos to evaluate their current state. Before I was using a few accessors in Foo to see these parts, until I realized that FooManager is the only class actually using these. I decided to make FooManager a friend of Foo...

How do you build an ASP.NET server control with multiple custom properties that are not in the same assembly?

Ok, this is a tricky one and has been bugging me now for a day and a half. Please read carefully as it is easy to misunderstand. I have seen the post http://stackoverflow.com/questions/123616/how-do-you-build-an-asp-net-custom-control-with-a-collection-property and I realise that is a solution, however, it relies on the fact that the P...

Non-blocking concurrent collection?

System.Collections.Concurrent has some new collections that work very well in multithreaded environments. However, they are a bit limited. Either they block until an item becomes available, or they return default(T) (TryXXX methods). I'm needing a collection that is thread safe, but instead of blocking the calling thread it uses a c...

How can I order TreeMaps or ArrayLists holding Persons based on their ID, name, or birthdate?

I have tried almost everything and I can't seem to get my lists to order themselves. Here's some code: private List<Person> names = new ArrayList<Person>(); private Map<Integer, Person> peopleMap = new TreeMap <Integer, Person>(); for(int i = 0; i<20; i++) { Person personOne = new Person(); peopleMap.put(personO...

Nhibernate custom loader for collection

Im really hoping someone can help with this, have been trying various combinations for a day and a half now.... Basically I have a some hierarchical data stored in a single table, the usual parentID maps to a row id scenario. I have modelled a property within the domain object that returns a list of ancestors for a given item. It all s...

ordered map implementation

Hi, I'm looking for a Map implementation that iterates over the key-value pairs in the order in which they were added. For example Map orderedMap = // instantiation omitted for obvious reasons :) orderMap.put(4, "d"); orderMap.put(10, "y"); orderMap.put(2, "b"); for (Map.Entry entry : orderedMap.entrySet()) { System.out.println(entr...

C# serialising data structure with objects in multiple lists/collections

In C# I wish to serialise a data structure where objects can belong to more than one collection. For example, I have a Person class. I also have a Family class and School class, which each contain a MemberList. An instance of the Person class can be present in both the MemberList of the Family and the School. I wish to serialise the en...

Frequent inserts into sorted collection.

I have sorted collection (List) and I need to keep it sorted at all times. I am currently using List.BinarySearch on my collection and then insert element in right place. I have also tried sorting list after every insertion but the performance in unacceptable. Is there a solution that will give better performance? Maybe I should use ot...

Scala collection: totally unpredictable behaviours...

Have been pretty frustrated by Scala 2.8 collection behaviours. Here's the problem: I'm creating a Sudoku board. I'm labelling the cells from A1 to I9 (the letters being the rows and the digits being the columns). I want to get a list of units on the board, which is the 9 rows, the night columns, and the night quadrants. Here's my scala...

The easiest way to transform collection to array?

Suppose we have a Collection<Foo>. What is the best (shortest in LoC in current context) way to transform it to Foo[]? Any well-known libraries are allowed. UPD: (one more case in this section; leave comments if you think it's worth to create another thread for it): What about transforming Collection<Foo> to Bar[] where Bar has construc...

Create a List<string> from HashTable keys?

Hey, how could I do this as short as possible? Thanks :-) ...

Is there a way of creating an IdentityMap in scala 2.8

There used to be an IdentityHashMap in collection.jcl: is there a way of constructing the same thing in the new 2.8 collections library (perhaps with a bespoke equality-relation)? ...

Ruby on Rails - Which method should I override for Album.first.photos?

I've overrode the method find for ActiveRecord::Base and that went pretty well, now I can customize it nicely. def self.find(*args) # my custom actions super(*args) end then Album.find(1) #=> My custom result But now I would like to override this: Album.first.photos and I'm not sure what method exactly I should override to ...

Java primitive collections library

What is the best Java primitive collections library? (most memory and time efficient) I've found Trove and FastUtil to be the most used ones, but haven't found much comparison between them (or between others) Is there any comparison available? ...

Queue<T> DataContractJsonSerialization in Silverlight 4.0

Can anyone serialize a Queue using the DataContractJsonSerializer in Silverlight 4.0 ? Here is some example code that throws. If not what additional collections can not be serialized using the Json Serializer ? public String Serialize() { String jsonString = String.Empty; using (MemoryStream s = new MemoryStream(...

Client side validation of list in ASP.Net MVC 2

Hi all, I've used stackoverflow many a time to solve my problems (code related!) but this is the first time I've needed to post a question cause I cannot work out whats wrong. When I enable client side validation on a view that allows editing of a collection of objects which use DataAnnotations for validation the following exception is...

How to get information from a list that is on another site collection, on SharePoint 2010?

Using SharePoint 2010, how can I get the information on a list that is on another site collection? ...

.NET parallel processing of ArrayList

Hello everyone, I am attempting at embedding multi-threading for the first time ever and running into some unexpected issues, hope you can help. Here's the code fragment that gives me troubles: ArrayList recordsCollection = new ArrayList(); ArrayList batchCollection = null; int idx = 0; while(true) { // Some code to generate and as...