collections

Trying to figure out how to allow a user to edit a collection with a DataGrid

I'm working on a plug-in for a 3D modeling program to assist in architectural design. I have a Building class which needs to contain a collection of Floors. My Floor class has properties such as Elevation, Height, ProgramType (residential, retail, etc), and ID. Each building has a FloorList property which is the collection of all the ...

NHibernate collection mapping throws 'could not load or initialize object or collection'

Hi, I've got following mappings: <bag name="BList" table="A_TABLE" inverse="true" lazy="false" cascade="all-delete-orphan"> <key column="A_ID"/> <one-to-many class="B, Model" /> </bag> And <many-to-one name="A" class="A, Model" column="A_ID" not-null="true" /> Performing insert and up...

Creating a custom collection that can be bound to a DataGrid

I work for an Architecture firm and I am creating a plug-in for a 3D modeling program to assist design. I have a Building class, and a Floor class. The building contains a reference to a FloorList collection of floors. I'm trying to figure out what to base the FloorList collection off of so that I can minimize the amount of work I need t...

NHibernate tracking entity and collection changes

I have a service layer returning a collection of entities : /// <summary> /// Returns list of all existing accounts. /// </summary> IList<Account> GetAllAccounts(); This is called on UI layer to get IList collection and bind it to UI via IBindingList : public BindingList<Account> Accounts { get; private set; } public voi...

Standard Collection for IDisposable objects

I've got a bunch of IDisposable objects in a lookup table (plain old Dictionary<>, right now), but to simplify the code and avoid error's I'm looking for a collection class which "owns" the items it holds, and to avoid reinventing the wheel - does such a class already exist? The specification should be that: - The collection must be di...

C# foreach over properties of objects contained within a Dictionary<String, ObjectType>

Is it possible to itterate directly over properties of the objects stored within a Dictionary collection in C#? For example, I have a Dictionary called Fields of type Dictionary<String, Field>. The Field object has a property of Data which is of type XmlDataDocument so I would like to do something like, foreach(XmlDataDocument fieldDat...

System.InvalidOperationException: Collection was modified ...

I am getting a following exception while enumerating through a queue: System.InvalidOperationException: Collection was modified; enumeration operation may not execute here is the code excerpt: 1: private bool extractWriteActions(out List<WriteChannel> channelWrites) 2: { 3: channelWrites = new List<WriteChannel>()...

IEnumberable to something that I can get a Count from?

I've got this: private IEnumerable _myList; I need to get a count off of that object. I was previously typing _myList to an array and getting the length, but now we are using this same bit of code with a different kind of object. It's still a Collection type (it's a strongly typed Subsonic Collection object), and everything works gr...

Managing collections of tuples in Objective-C

I am fairly new to Objective-C and was wondering what the best way to manage collections of tuples was. In C I would use a 2D array or a struct. Should I be creating objects to contain these tuples? It seems like overkill for just sorting lists or is there no real extra load generated by object initialisation? ...

When should I use Iterable vs. Collection in Java?

What are the considerations of using Iterable<T> vs. Collection<T> in Java? For example, consider implementing a type that is primarily concerned with containing a collection of Foos, and some associated metadata. The constructor of this type allows one-time initialisation of the object list. (The metadata can be set later.) What type s...

Linq to update a collection with values from another collection?

I have IQueryable<someClass> baseList and List<someOtherClass> someData What I want to do is update attributes in some items in baseList. For every item in someData, I want to find the corresponding item in baselist and update a property of the item. someOtherClass.someCode == baseList.myCode can I do some type of join with Linq and...

What is the Collections.checkedList() call for in java?

I just want to know for what java.util.Collections.checkedList() is actually used. I have some code that I know is returning me a List<String> but its being passed through a chain of messaging calls and returned to me as a java.io.Serializable. Is that checkedList call good for me to turn my Serializable into a List<String>? I know...

How can I get an int[] out of an Iterator?

I have what amounts to an Iterator<Integer>... actually it's a class Thing that accepts a Visitor<SomeObject> and calls visit() for a subset of the SomeObjects it contains, and I have to implement Visitor<SomeObject> so it does something like this: // somehow get all the Id's from each of the SomeObject that Thing lets me visit public i...

What is the collection equivalent of a multi-dimensional aray?

I've got a group of data that looks like this: 001 001 One 001 002 Two 001 003 Three 002 001 One 002 002 Two 002 003 Three ... Now, certainly, I could create an array of string[x][y] = z, but this array has to be resizable, and i'd prefer to use the string representations of the indexers than convert to numeric. The reason is that ...

Magento: Select the top ordered products

I need a block where i can display my "top sellers" but don't know how i can do the collection select. What "addAttributeToSelect" do i need? ...

What is the best C# collection with two keys and an object?

I've got a MenuManager class to which each module can add a key and and element to be loaded into the main content: private Dictionary<string,object> _mainContentItems = new Dictionary<string,object>(); public Dictionary<string,object> MainContentItems { get { return _mainContentItems; } set { _mainContentItems = value; } } So...

Immutable struct with collection

I'm making an immutable struct in .Net which contains a read only collection of a different immutable struct (I have full control over the entire design). I don't need a non-mutating Add method. What's the best way to do that? I could make the outer struct have a reference to a ReadOnlyCollection containing the inner struct. Are ther...

When would I use List<T>.ForEach over a native foreach loop?

Are there advantages to either approach? If I need to traverse List items and perform an action on each one, should I use the traditional foreach loop mechanism or move on to List.ForEach? Matthew Podwysocki @ CodeBetter.com wrote an interesting article about the anti-for campaign. This got me thinking about the problem a loop is tr...

How to I add an item to a Dictionary<string, Dictionary<string, object>>?

I want users of my LayoutManager class to be able to write this: LayoutManager layoutManager = new LayoutManager(); layoutManager.AddMainContentView("customers", "intro", new View { Title = "Customers Intro", Content = "This is customers intro." }); But what syntax do I need to fill this dictionary in a dictionary in AddMainConte...

Passing a generic collection of objects to a method that requires a collection of the base type

Say I have a method that is expecting a generic collection parameter of a base type, see Test.MethodA(IEnumerable(BaseClass) listA) below. How come when I pass it a collection of a derived type the code wont build? Wouldn't all instances of DerivedClass also be a BaseClass? I could have just created a new List(BaseClass) and passed that...