collections

Reflection PropertyInfo.GetValue from Collection

I have problem with reflection, dynamic invoking objects and reading collection values. In Referenced COM/Interop it would look like this: ICollection collection = (ICollection)sth.getCollection("parameter"); SomeObject obj = (SomeObject)collection["id='1'"]; //DB WHERE condition Unfortunetly i need to make it with reflection and dyna...

Java: Manipulation of Lists with super classes.

Suppose I have MyEdge and MyEdgeModified, such that MyEdge is the superclass and MyEdgeModified is the subclass. Now, suppose I do this: List<List<MyEdge>> collectionOfEdgeLists = new LinkedList<List<MyEdge>>(); for(int i = 0; i < someValue; i++) { List<MyEdgeModified> newList = someMethod(); collectionOfEdgeLists.add(newList); ...

Can I have a Untyped Collection in C#

I am porting some Java code to C# and I ran across this: List<?> As I understand it this is a List of type Unknown. As a result I can dictate the type elsewhere (at runtime? I'm not sure). What is the fundamental equivalent in C#? ...

which collection should be used depending on the performance ?

I am developing the asp.net mobile application. I am using xml as a database. In the following xml file I am retriving the all the attributes by using LINQ to xml. In this way there are nearly 10 to 30 attributes. I am adding the values of these attributes dynamically into the Hashtable. In coding part I am using following code...

Optimization: How should i Optimize the Linq Concat of Collections? C#

is there any way i can Optimize this: public static IEnumerable<IEnumerable<int>> GenerateCombinedPatterns (IEnumerable<IEnumerable<int>> patterns1, IEnumerable<IEnumerable<int>> patterns2) { return patterns1 .Join(patterns2, p1key => 1, p2key => 1, (p1, p2) => p1.Concat(p2)) .Where(r => r.Sum() <= sto...

How to combine two observable collections into collection in Silverlight

Hello, I am currently trying to combine two collections into one for binding to a combobox. I first started out with two static collections built within a class: public partial class MainPage : UserControl { //create static observable collection private ObservableCollection<string> items; public ObservableCollection<strin...

Get table values in a collection for the same value in any one row using LINQ

I have a table with column having multiple identical values which associates with other row values. ID HValue Limit 0005 0 350.00 0005 1 0.00 0005 2 350.00 0005 3 350.00 0025 0 20.00 0025 1 0.00 I executed the stored proc and stored t...

Is it possible to map collections of primitive types with EF4?

Is there a way to map a collection/dictionary of primitive types in Entity Framework. I would like to have: public class Abc { public virtual long Id {get;set;} public virtual ... some properties public virtual IList<float> Numbers; // or even: public virtual IDictionary<DateTime,decimal> MoreNumbers; ...

Replacing a ListView's ItemsSource Without Loosing SelectedItem

Hello, I'm data-binding a ListView to a collection that comes from a service layer. In response to events, the view model associated with the ListView refreshes the ListView's data. In order to retrieve updated data, the vm retrieves a new collection instance from the service layer. Items in this collection are Equals() but not Referenc...

What is static <E>?

Dear all, I am just reading through collection java tutorial and wondering why the <E> is needed after static? public static<E> Set<E> removeDups(Collection<E> c) { return new LinkedHashSet(c); } Thanks, Sarah ...

Get all Roles, But a select few Help

Hello, I have run into a problem where I need to remove certain items from collections that seem to only have get all functions. My Idea is to get the full collection and then remove the unneeded items. Then take that new collection and bind it to whatever I need. For example How do I get all the roles except administrator? Roles s...

Trouble with Generic List and add wrapper

I admit that I don't have a lot of experience with using Java Generics. Right now, I'm retrofitting some old code with Generics to reduce/simplify existing code written by a colleague who has since left the company. Basically, the system I'm working on has 6 request types: 1 General, and 5 specific that inherit from General. Each requ...

.NET List best approach

I have a list which is declared below, at the start I default the list items to { -1, - }. please note that throughout the program the list size is fixed at 2. List<int> list = new List<int>(new int[] {-1, -1}); My question is regarding, what would be the best approach if I need to overwrite the two values in the list. int x = GetXVa...

Collection as a metaphor for real world containers

I find modeling physical containers using collections very intuitive. I override/delegate add methods with added capacity constraints based on physical attributes such as volume of added elements, sort based on physical attributes, locate elements by using maps of position to element and so on. However, when I read the documentation of ...

+= appends to stack in Scala 2.7.7; :+ does not seem to work in Scala 2.8.0

Using Scala 2.7.7, this works as expected: import scala.collection.mutable.Stack ... var x = new Stack[String] x += "Hello" println(x.top) After changing to Scala 2.8.0, the += should be replaced by :+. However, this does not append to the stack: java.util.NoSuchElementException: head of empty list. Am I overlooking something basic? ...

Merge elements in IEnumarable according to a conditon

Hello Everyone, I was looking for some fast and efficient method do merge items in array. This is my scenario. The collection is sorted by From. Adjacent element not necessarily differ by 1, that is there can be gaps between the last To and the next From, but they never overlap. var list = new List<Range>(); list.Add(new Range() { Fro...

Spring mvc, how to bind a domain object that has a collection as its property

I have a domain object called Order, and it has a collection attribute called serviceOrders where a collection of service --- order m:m association relationships are hold. public class Order implements Serializable { private Long id = null; private BigDecimal amountPaid; private BigDecimal accountReceivable; private User user; p...

How do I use the 'map' method in an ActiveRecord class method?

Not sure on my Ruby syntax here. I want to define a method that I can call like this: client.invoices.average_turnaround. So my average_turnaround method needs to work with a collection of ActiveRecord objects. Here's my code thus far: class Invoice < ActiveRecord::Base ... def self.average_turnaround return self.map(&:turnaro...

Is it possible to add two IQueryable's together?

I've been using Union on IQueryable<> (with the same type) to try to get one collection produced from two collections, but it is not working. I believe my understanding is at fault with regards to the IQueryable members. I thought I could use the union method to build (within a foreach) a SQL statement which would execute something like...

Best c# collection for large keys

I am developing a multilingual ASP.NET web site. I want the users to be able to add translations 'on the fly' therefore I am storing the translations in a database and maintaining an ASP.NET Application object containing all the translations (for performance). I am using a simple Hashtable to store the translations, then I store this i...