collections

C# Application performance deterioration due to garbage collection?

My application's performance deteriorate as it continues to run through the day. I suspect it is garbage collector, how can I verify this? Is there a way to find out which object/function is causing garbage collection overhead? Is there a way to manually perform garbage collection programatically to clear memory of leakages? Thanks, ...

Create array (collection) of buttons from existing buttons

Hi - is there a simple way of creating a button collection from the existing buttons on my form? (In c#). I have a series of buttons already on my form and I want to use an index to access them...e.g.: myButtonArray[0].ForeColor ...// Do something with it Can this be done? Edit: Can I set the array to have a generic OnClick event? A...

Which collection to use in Java ?

I want to map integers to strings, they are one-to-one such as : 60 : c 61 : c# 62 : d 63 : d# 64 : e 65 : f 66 : f# But I need to have the ability to do the following : Get a value from a key : "c" = getValue(60) [ give it a key 60, return string value ] get key from a value : 65 = getKey("f") [ give it a string value "f", retur...

How do I query an object collection using user defined conditions?

Sorry if this is a little abstract. I'm in the early stages of development. I have two object types: An object that needs to store a series of user defined conditions. An object that matches zero or more of the conditions defined in the first object. Here's a simple example of how it would run. A user creates several objects of ty...

How to convert variadic function arguments into collection such as Set or List

Dear all, In Java, we can use variadic function in the following way: public Set packStrings(String...strings){ for (String str : strings){ //Do something on the str } //How to convert strings into a Set? } My question is, what is the type of "strings"? is it String[]? How to put the string(s) denoted by the "st...

Freemarker 'Collection.contains' functionality

From my java code I'm returning a Set<String>. The view needs to check if the Set contains a specific string.. I can't find any docs on how Freemarker can handle this. Any idea? ...

convert String arraylist to string array in java?

How t convert string array list to string array in java ? ...

Is the List<T>.AddRange() thread safe?

Can I, without locking, safely call List.AddRange(r) from multiple threads? If not, what sort of trouble would I run into? ...

Mapping Java collections which contains super- and sub-types with JAXB

I'm trying to produce something like this with JAXB: <person> <firstName>Foo</firstName> <lastName>Bar</lastName> <identities> <green id="greenId"> <some_elements.... </green> <blue id="blueId"/> </identities> The child elements of <identities> all stem from a common super-class. In Jav...

What is the correct way to initialize collection of an entity (POJO) in Spring-Hibernate project?

I have a POJO class, say Foo, which has a Set of other entity instances, say bars. Also there are standart misc classes for such project: service and dao for both Foo and Bar. I want BarService to get the Set of Bar instances associated with some Foo. Now I have the following code, wich I believe is conceptually bad. public class Foo...

Binding a Dictionary(Of Integer, String) to the DataTextField property of a DropDownList

I have a State class defined like this: Public Class State Public Property StateId As Integer Public Property Name As Dictionary(Of Integer, String) End Class Name(x) contains the state name in different languages. I get a collection of State from the method StateManager.GetAllStates() and I want to bind this collection to a...

Reversing LinkedList in Java

I am looking at the solution in this post http://stackoverflow.com/questions/354875/reversing-a-linked-list-in-java-recursively I copied the one of the solutions below. I've implemented it and it works fine. public ListNode Reverse(ListNode list) { if (list == null) return null; // first question if (list.next == null) return ...

Why does exist WeakHashMap, but absent WeakSet?

Hi! From J. Bloch A ... source of memory leaks is listeners ... The best way to ensure that callbacks are garbage collected promptly is to store only weak references to them, for instance, by storing them only as keys in a WeakHashMap. So, why there isn't any WeakSet in java collection framework? Thanks. ...

Correct use of Hashtable with custom class

This piece of code generates unexpected output. Hashtable<Pair, Integer> results = new Hashtable<Pair, Integer>(); results.put(new Pair(0, 1), 2); System.out.println("[DBG] " + results.containsKey(new Pair(0, 1))); The output is [DBG] false. Why did Hashtable fail to register this element? Does it have something to do with the way I t...