collections

Accessing column from Collection of Collection using Hibernate mapping

Req.hbm.xml: <id name="reqId" type="long" column="REQ_ID"> <generator class="sequence"> <param name="sequence">SEQUENCE</param> </generator> </id> <bag name="lines" lazy="false" > <key column="REQ_ID" not-null="true" /> <one-to-many class="com.Lines" /> </bag> Lines.hbm.xml <id name="lineId" type="...

Image not updated in item added to custom list

I have a item with Image field, and a custom list derived from CollectionBase. When I add the item to the custom list, and then try to change that item Image and then get the item from the list, the Image is not set on the list item. How to make sure that the item in the list is the same as the item we created and any update will be sync...

Casting a generic collection to base type

I've got an IList<DerivedClass> that I want to cast to ICollection<BaseClass> but when I attempt an explicit cast, I get null. Is it possible to do this without creating and populating a new collection? Edit: Since I only want to read from the collection, I switched to using a generic method: public void PopulateList<BaseClass>(IColle...

Hibernate: Collections of Collections

This is a problem I keep on running into: I would like to have hibernate manage a single table that represents a collection of collections. For example: a Map of Maps List of Sets Map of Lists Example, I would like to be able to represent this: class OwningClass { Long entityId; Map<String, List<Element>> mapOfLists; }...

System.Collections - why so many options?!

Most of my programming experience is in a language where there is one collection data structure -- an array. Now that I'm working primarily in .NET, I've come to appreciate the vast number of tools available to me, but I also find it difficult to determine which tools is best suited for each problem. I find this to be the case often wi...

C# Problem with two sorted Views ( ListCollectionView ) on the same collection

Hi, I have two windows that have a listbox bound to a ListCollectionView, both are sorted with the same SortDescription, View1 and View2 When i add item through View2 its reflected in View1 and i can see the label after the focus change event, then View2 gets sorted. and View1 is now unsorted. How can i slove this issue? Thanks, Eric...

Alphabetically Sort a Java Collection based upon the 'toString' value of its member items.

Assume I have a user defined Java class called Foo such as: public class Foo { private String aField; @Override public String toString() { return aField; } } and a Collection such as: List<Foo> aList; What I am looking to do is to sort the List alphabetically based upon each member's returned '.toString(...

VB.NET Object Problem with Collections, Arrays and Lists

I have a small program where I have been trying to create collections of a particular object I have created (Job). Regardless of whether I am using an array, collection or list, each time I add a new instance of the object to the array/collection/list, it overwrites all previous items with the same object. For example, let's say Job ha...

WPF ListView Databound Drag/Drop Auto Scroll

Hi there, I've been working with Bea's solution here for a while and finding it very helpful. Problem now I'm having is when I drag-n-drop items within or to another ListView control and I want to scroll up/down "during" the drag (moving an item from index 30 to index 1), it's not happening. I would have to drag to the top of the visua...

Big-O summary for Java Collections Framework implementations?

I may be teaching a "Java crash-course" soon. While it is probably safe to assume that the audience members will know Big-O notation, it is probably not safe to assume that they will know what the order of the various operations on various collection implementations is. I could take time to generate a summary matrix myself, but if it's...

Initializing a collection so the user doesn't have to

This might be a stupid question, but is there any common practice for initializing collection properties for a user, so they don't have to new up a new concrete collection before using it in a class? Are any of these preferred over the other? Option 1: public class StringHolderNotInitialized { // Force user to assign an object to ...

Best way to control concurrent access to Java collections

Should I use old synchronized Vector collection, ArrayList with synchronized access or Collections.synchronizedList or some other solution for concurrent access? I don't see my question in Related Questions nor in my search (Make your collections thread-safe? isn't the same). Recently, I had to make kind of unit tests on GUI parts of o...

java.util.ArrayList<T>

This is the implementation of java.util.Arrays.asList: () public static <T> List<T> asList(T... a) { return new ArrayList<T>(a); } How can that compile? I can't find a constructor for ArrayList, AbstractList or AbstractCollection that accepts a parameter like T... och T[]. Source code from: java version "1.5.0_16" Java(TM) 2 Run...

how to generate custom collection type in .Net from WSDL?

I am running a custom application that imports WSDLs and generates C# source code, using WSDLImporter class to read in contracts. XSD sequence types are translated into native arrays. What options can I set in order to be able to generate custom collection types? Schema: <xs:complexType name="getAllSourcesResponse"> <xs:sequence...

Export object collection to XML file

Using C#...I have a small app that creates objects from a class, and adds them to an object collection and it does some UI stuff along the way to display certain values from the currently selected object in the collection (Using WPF UI). So I want to add the ability to let the user save his object collection to a file, so they can load i...

How do I convert a Groovy String array to a Java String Array?

I'm trying to call a methond on a Java class from a Groovy class. The Java method has a String array as a parameter, and I have a collection of Strings in my Groovy class. How do I convert the Groovy collection to a Java String array? Java Method: public class SomeJavaClass{ public void helpDoSomething(String[] stuff){ } } Gro...

ArrayList versus an array of objects versus Collection of T

I have a class named Customer (with typical customer properties) and I need to pass around, and databind, a "chunk" of Customer instances. Currently I'm using an array of Customer, but I've also used Collection of T (and List of T before I knew about Collection of T). I'd like the thinnest way to pass this chunk around using C# and .NET ...

Best hybrid approach to a multi-dimensional array with strong typed indexing

I have what amounts to a multi-dimensional array. int[][][] MyValues; What I want is to access the indexes via a strongly typed equivelent, such as an enumeration. I'm aware that you can get the enumeration values from the Enum type, but it's a bit long winded for my tastes. I'd rather have a way to Strongly type the indexes. For e...

Optimizing the speed of insertion in java.util.Map/Set

Hi all, is there a way to optimize the speed of the insertions in a java.util.Collection by specifying the order of the items ? For example java.util.Set<String> set = java.util.TreeSet<String>(); will this solution: set.add("A"); set.add("B"); set.add("C"); set.add("D"); set.add("E"); be faster than this one (random order) ? set...

.net collection for fast insert/delete

I need to maintain a roster of connected clients that are very shortlived and frequently go up and down. Due to the potential number of clients I need a collection that supports fast insert/delete. Suggestions? ...