collections

When is a ConcurrentSkipListSet useful?

I just saw this data-structure on the Java 6 API and I'm curious about when it would be an useful resource. I'm studying for the scjp exam and I don't see it covered on Kathy Sierra's book, even though I've seen mock exam questions that mention it. ...

Can Objects in Objects be persistent? (vb .net)

Hi*, Dim BigCollection As New Collection Dim SmallCollection As New Collection SmallCollection.Add("Hello World") BigCollection.Add(SmallCollection) MsgBox(BigCollection(1)(1)) 'shows "Hello World SmallCollection.Clear() MsgBox(BigCollection(1)(1)) 'ERROR (Collection is empty) I want that once I put something in the BigCollection it ...

Hibernate collection handling basics

Hi all, I"m new to Hibernate. I have 3 tables: Companies, Profiles and Sites. The relation is - one company has many Profiles and Sites (one-to-many). <hibernate-mapping> <class name="com.bla.dataobject.CompanyData" table="companies"> <id name="companyId" column="company_id"> <generator class="increment"/> </id> <property name="...

C# associative array

I've been using a Hashtable, but by nature, hashtables are not ordered, and I need to keep everything in order as I add them (because I want to pull them out in the same order). Forexample if I do: pages["date"] = new FreeDateControl("Date:", false, true, false); pages["plaintiff"] = new FreeTextboxControl("Primary Plaintiff:", true, tr...

C# -- Need an IDictionary implementation that will allow a null key

Basically, I want something like this: Dictionary<object, string> dict = new Dictionary<object, string>(); dict.Add(null, "Nothing"); dict.Add(1, "One"); Are there any built into the base class library that allow this? The preceding code will throw an exception at runtime when adding the null key. Thanks ...

loop on list with remove

for (String fruit : list) { if("banane".equals(fruit)) list.remove(fruit); System.out.println(fruit); } Here a loop with remove instruction. At execution time, I get some ConcurrentModificationException, below the console output: Exception in thread "main" java.util.ConcurrentModificationExcepti...

.NET - how does IndexOf work if I don't implement IComparable in my class?

I have a collection of custom object, and I am doing IndexOf to find the index of a specific object. I would assume that the IndexOf would use IComparable implementation to check to see if the objects match, but I am not implementing it in my class. How does IndexOf determine that two objects are equal? Thanks! ...

Generic collection of generic classes?

I have a class that I fill from the database: public class Option<T> { public T Value { get; set; } public T DefaultValue { get; set; } public List<T> AvailableValues { get; set; } } I want to have a collection of them: List<Option<T>> list = new List<Option<T>>(); Option<bool> TestBool = new Option<bool>(); TestBool.Value = tr...

Why isn't Collections.binarySearch() working with this comparable?

I have this Player class which implements the Comparable interface. Then I have an ArrayList of Players. I'm trying to use binarySearch() on the list of Players to find one Player, but Java is giving me a "cannot find symbol: method binarySearch(java.util.ArrayList< Player>,Player)". This the Player class: class Player implements Compa...

Equivalent Spring custom Collection property editor when using JSF

Hi, I would like to know how to use Converters in Java Server Faces similar to Spring collection property editor Suppose the following model public class Group { private String name; List<User> users = new ArrayList<User>(); // getter's and setter's } And equivalent form <form ...> <h1>Group form</h1> <label ...

Help Linqifying collection to Dictionary

I'm refactoring this code and was trying to think of a simple linq expression to populate this Dictionary. IEnumerable<IHeaderRecord> headers = PopulateHeaders(); var headerLocationLookup = new Dictionary<string, IHeaderRecord>(); foreach (var header in headers) { //destination locations can repeat, if they do, dictionary should only ...

Can NHibernate save a collection without an iterator?

Simple question: can NHibernate save a collection without an iterator? For example: var list = new List<Item>(); list.Add(1000 items); session.Save(list); Or do I have to do foreach over the list? ...

User defined filters/queries?

I'm trying to figure out a way to allow users of my application to define their own queries or filters that can be applied to a collection. I want to eventually provide an intuitive user interface to create these filters (see image below), but initial it would be OK if a user had to type of a text query string. I'll also need to be able ...

Declaring collections in C#

Hello, My question is: What is the most efficient and correct, for large set of data ? _pointBuffer1 = new Point3DCollection { new Point3D(140.961, 142.064, 109.300), new Point3D(142.728, 255.678, (...) -- or -- _pointBuffer1.Add(new Point3D(140.961, 142.064, 109.300)); _poitBuffer1.Add(142.728, (...) Or is it the s...

stroring duplicate key value pair C#

I have a data like in (string , int) pair. How to store this data in collection object. Both values can be duplicate. Which collection object should i use?? EDIT: How can i access elements separately..?? ...

Implementing IEnumerable on a tree structure

Based on the work of these guys: dvanderboom.wordpress.com/2008/03/15/treet-implementing-a-non-binary-tree-in-c/ www.matthidinger.com/archive/2009/02/08/asp.net-mvc-recursive-treeview-helper.aspx I am trying to implement a TreeView helper that would be used as such: <%= Html.TreeView("records", Library.Instance.Reco...

collections and application wide use?

Here's a specific problem that I run into when creating objects, such as collections, that need to be available through the whole scope of the application. I have the following class: class UserDataCollection { List<UserData> Collection = new List<UserData>(); UserData current; public UserData Current ...

How do I swap items in a VB6 collection?

If I have a collection of forms (myForms) and I want to switch the position of two forms in the collection (say items 3 and 4 for example), I would expect that the following code would work: Dim temp as Form Set temp = myForms(3) Set myForms(3) = myForms(4) Set myForms(4) = temp But that doesn't work. It fails at the third line with ...

Generic type inference with interface inheritance (co(ntra)-variance?) in C# 3

I have the following two generic types: interface IRange<T> where T : IComparable<T> interface IRange<T, TData> : IRange<T> where T : IComparable<T> ^---------^ | +- note: inherits from IRange<T> Now I want to define an extension methods for col...

How do I form the union of scala SortedMaps?

(I'm using Scala nightlies, and see the same behaviour in 2.8.0b1 RC4. I'm a Scala newcomer.) I have two SortedMaps that I'd like to form the union of. Here's the code I'd like to use: import scala.collection._ object ViewBoundExample { class X def combine[Y](a: SortedMap[X, Y], b: SortedMap[X, Y]): SortedMap[X, Y] = { ...