collections

Java Collections with Mutable Objects

How does a TreeSet, HashSet or LinkedHashSet behave when the objects are mutable? I cannot imagine that they would work in any sense? If I modify an object after I have added it; what is the behaviour of the list? Is there a better option for dealing with a collection of mutable objects (which I need to sort/index/etc) other than a lin...

Fluent Nhibernate - How do I set the name attribute of a set or bag collection?

This is a set collection: <set access="field.camelcase-underscore" cascade="save-update" inverse="true" lazy="true" name="employees" table="TeamEmployee" mutable="true"> How do I set the name attribute? ...

What is a java collection?

I want to know: What is a collection in Java? ...

hibernate query.list() method is returning empty list instead of null value

When there are no rows, both query.list() and criteria.list() are returning empty list instead of a null value. What is the reason behind this? ...

Comparing two lists and removing duplicates from one

I have an object called FormObject that contains two ArrayLists - oldBooks and newBooks - both of which contain Book objects. oldBooks is allowed to contain duplicate Book objects newBooks is not allowed to contain duplicate Book objects within itself and cannot include any duplicates of Book objects in the oldBooks list. The definitio...

Problem persisting read/write collection at design-time in .Net Winforms.

I have a requirement to persist a collection at design-time: Public Class MyButton Inherits Button Private _MyCol As MyCol <Editor(GetType(MyColEditor), GetType(UITypeEditor))> _ Public Property MyCol() As MyCol Get Return _MyCol End Get Set(ByVal value As MyCol) _MyCol = ...

What ListBox like control is used in Collections Editor of Visual Studio.

I need to create a from which uses the same ListBox as the one from Collection Editor of Visual Studio (The ListBox under the Members label). Please, explain exactly which WinForms control is this and which of its properties are set? You can see the control I am asking about under the Members: label of every collection editor form in d...

Creating a comparable Dictionary Key

I want to use a Dictionary(Of Key, Value), and the Key is not a base type, but a class like: Public Class MyKey Sub New(ByVal packet As String, ByVal sent As Boolean) Me.packet = packet.ToUpper.Trim Me.sent = sent End Sub Private packet As String Private sent As Boolean End Class Now to have the Dicti...

Are there plans for ImmutableEnumSet in Java 7?

I want to have all the efficiencies of EnumSet and pass it around without worrying that somebody would modify it. ...

Is it faster to add to a collection then sort it, or add to a sorted collection?

If I have a Map like this: HashMap<Integer, ComparableObject> map; and I want to obtain a collection of values sorted using natural ordering, which method is fastest? (A) Create an instance of a sortable collection like ArrayList, add the values, then sort it: List<ComparableObject> sortedCollection = new ArrayList<ComparableObject...

java collection

give me a simple trick to understand java collection properly.. you can give a website address also.. ...

Why PriorityQueue in Java cannot have initialCapacity 0?

I use PriorityQueue for partial sorting of some data. In particular, this is the code: Collection<Data> data = ...; PriorityQueue<Data> queue = new PriorityQueue<Data>(data.size(), dataComparator); queue.addAll(data); // iterate over queue with remove() until we have as much data as we need or until queue is empty Unfortunately, when ...

WebService: How to return an array of a complex type?

2 Questions really, and I'm not sure if I'm doing this right or not... I want to send back an array of some sort for an Entity object I created. I'm not really sure how to mark it for sending (what attributes are needed or whatever), and I'm not really sure how to send it back (IList, List, Collection, ICollection). Ideally I'd love to...

symfony doctrine - insert/update Doctrine object from Excel

Hi! On the project which I am currently working, I have to read an Excel file (with over a 1000 rows), extract all them and insert/update to a database table. 1ª Question: in terms of performance, is better to add all the records to a Doctrine_Collection and insert/update them after using the fromArray() method, right? One other possib...

Storing dates, which structure? c#

Say I have a list of 1000 random dates, call it L I dont think c# has a 'Tree' collection, so Im wondering how to implement the following: The tree will be 3 stages deep, the first stage contains the year, the next stage contains all months in L in the parent year, and the final stage contains all days in the 'parent' month, and 'grand...

Adding element to a collection in a JSP in Spring MVC

I am displaying values from a set on a bean called AttributeDefinition which has a Set of ValidValues. I am able to display the set and change the values using the JSP below: <c:forEach items="${attributeDefinition.validValues}" var="validValue" varStatus="validValueRow"> <form:hidden path="validValues[${validValueRow.index}].id"/> ...

Does an object in java have any memory size constraints?

Can we have any size of Java object without any fear of exception? I am going to use an object of a class that consists of an ArrayList of thousands of other objects that contains couples of HashMaps and ArrayLists and many other non primitive type. Thank you ...

Why doesn’t java.util.Collection define next(), hasNext() directly?

If Collection defines hasNext() instead of iterator().hasNext(), we could write loop easier: while(collection.hasNext()){…} instead of: Iterator it= collection.iterator(); While(it.hasNext()){…} Of course, I know easy way for loop for(E e:collection) exists. Why interface Iterator exists? ...

IntMap changes type after innocent mapping

consider this piece of code:Welcome to Scala version 2.8.0.r0-b20100714201327 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_20). scala> val a = IntMap((1,1)) a: scala.collection.immutable.IntMap[Int] = IntMap((1,1)) scala> a.map(x => (x._1,x._2 + 1)) res23: scala.collection.immutable.Map[Int,Int] = Map((1,2)) header of IntMap.map says t...

Rearranging a collection without Add/Removing items?

I have a TabControl that can be rearranged by dragging/dropping the tabs. The current process removes an item from the list and adds it to a new location. I had some performance issues switching tabs because of how complex the tabs are, so found an alternative which stores the rendered tabs and reloads them when requested. My only proble...