collections

How to remove items from an Observable Collection

Hello all, I appologize for the novel but I wanted to explain as much as I have done thus far. Within my current project I have an application that consumes a service that provides a collection as a <List>. Due to how I am using this data in the application I have had to convert this data to an observable collection. This was done so th...

Hiberante property type list, add it through sql to table

Hi all, I recently added new property in one class, its list property and I have written xml mapping for that property,due to few reasons I am not suppose to delete database or use create option in hibernate config file to update changes. I have to do it manual by executing sql queries on database. xml mapping file: <list name="items"...

Adding and retrieving from a KeyedCollection

I want to use a KeyedCollection to store a class against a string key value. I have the following code: public class MyClass { public string Key; public string Test; } public class MyCollection : KeyedCollection<string, MyClass> { public MyCollection() : base() { } protected override String GetKeyForItem(MyCla...

Creating lists and sets in Scala: What do I actually get?

If I create a Set in Scala using Set(1, 2, 3) I get an immutable.Set. scala> val s = Set(1, 2, 3) s: scala.collection.immutable.Set[Int] = Set(1, 2, 3) Q1: What kind of Set is this actually? Is it some hash-set? What is the complexity of look-ups for instance? Q2: Where can I read up on this "set-creating" method? I thought that it w...

Binding a Collection<bool> to togglebuttons/checkboxed

Hi, I have a collection of bools associated to days of the week - Collection() { true, false, false, false, false, false,false}; So whatever the bool represents means that this collection applies for sunday (sunday being the first day of week here). Now I have set the itemssource of my listbox, say, to be this collection. <ListBox Ite...

Standard API way to check if one array is contained in another.

I have two byte[] arrays in a method like this: private static boolean containsBytes(byte[] body, byte[] checker){ //Code you do not want to ever see here. } I want to, using the standard API as much as possible, determine if the series contained in the checker array exists anywhere in the body array. Right now I'm looking at some ...

Advanced search/queue array collection question

I have a pretty large number of objects "usrSession" I store them in my ArrayCollection usrSessionCollection. I'M looking for a function that returns the latest userSessions added with a unique userID. So something like this: 1. search the usrSessionCollection and only return one userSessions per userID. 2. When it has returned x num...

SOA WCF class design for collections of objects, or "has-a" object situations.

We are designing an object model from scratch for an application that will expose data via WCF. We are wondering about how to handle the case where objects that have a collection of objects within them. For example, a contact object with a collection of address objects. contact - list<address> Should we have a wrapper object, somethi...

Any advantage to objects.GetObject(i) over objects[i]?

I'm refactoring a little bit of C# data access code from a previous developer and am curious about a pattern he used. The code initially exposed collections (arrays) of a variety of ActiveRecord-style business objects - essentially objects wrapping database fields. I'm changing the arrays to generic lists, but the aspect of the code I'...

When is one Set less than another in Scala?

I wanted to compare the cardinality of two sets in Scala. Since stuff sometimes "just work" in Scala, I tried using < between the sets. It seems to go through, but I can't make any sense out of the result. Example: scala> Set(1,2,3) < Set(1,4) res20: Boolean = true What does it return? Where can I read about this method in the API? ...

Is there a way to convert an observable collection to a List?

I've got a test collection setup as : ObservableCollection<Person> MyselectedPeople = new ObservableCollection<Person>(); public MainWindow() { InitializeComponent(); FillData(); } public void FillData() { Person p1 = new Person(); p1.NameFirst = "John"; p1.NameLast = "Doe"; p...

Rails helper "Collection Select"

I have the exact same problem as this guy , since no one has answered, I decided to repost: 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> <op...

Java collections memory consumption

Say I instantiate 100 000 of Vectors a[0..100k] = new Vector<Integer>(); If i do this a[0..100k] = new Vector<Integer>(1); Will they take less memory? That is ignoring whether they have stuff in them and the overhead of expanding them when there has to be more than 1 element. ...

How to map custom collection in JPA?

Hello everybody! I have problems in mapping custom collection with JPA (Hiberante provider). For example when I am using object with attribute List<Match> matches; with <one-to-many name="matches"> <cascade> <cascade-all /> </cascade> </one-to-many> in my ORM file, it is allright; But if I replace "List matches;" ...

How to map NHibernate custom collection with fluentNHibernate?

I am trying to map the collection for two days without success. I also read all possible articles and forums but still down there. Ok, here is the problem: 1) The collection class contains a private field "_internalCollection" which is mapped with NHib. 2) The holding entity should expose the collection trough readonly property. 3) I ...

WPF - Reload an a collection (with 'new') without rebinding controls

Imagine the following: class Repository { private ObservableCollection<ModelClass> _allEntries; public ObservableCollection<ModelClass> AllEntries { get { return _allEntries; } set { _allEntries = value; } } public void RefreshDataFromDB() { _all = new ObservableCollection(GetMyData()); //...

Converting immutable to mutable collections

What is the best way to convert collection.immutable.Set to collection.mutable.Set? ...

Should I return an IEnumerable or IList?

I wish to return an ordered list of items from a method. Should my return type be IEnumerable or IList? ...

UML class diagram: to add fields used to implement relationships or not?

Hi all, I am trying to figure out if it is correct to put in the fields of the particular class a reference to an object/collection that this class is related with. Let's say I have a class University that aggregates many instances of Student class. When I put on my diagram both classes, I add the relationship of aggregation between th...

ConcurrentModificationException for ArrayList

I have the following piece of code: private String toString(List<DrugStrength> aDrugStrengthList) { StringBuilder str = new StringBuilder(); for (DrugStrength aDrugStrength : aDrugStrengthList) { if (!aDrugStrength.isValidDrugDescription()) { aDrugStrengthList.remove(aDrugStrength); } ...