if I do this in Java:
for(String s : myCollection.expensiveListGeneration())
{
doSomething();
}
is expensiveListGeneration() invoked just once at the beggining or in every cycle iteration?
Is it implementation dependent?
...
Class A
{
Guid ID{get;}
ISet<B> ClassBs {get;}
}
repository
public IList<B> GetAsBs(A a)
{
ICriteria ACriteria = Session.CreateCriteria(typeof(A));
ICriteria BCriteria = ACriteria.CreateCriteria("ClassBs");
A.Add(Restrictions.Eq("ID", a.ID));
return BCriteria.List<B>();
}
I can accomplish this in HQL np but want to use criteria
i am ...
I'm writing a plug-in for a 3D modeling program. There is a a feature of the API where you can intercept the display pipeline and insert additional geometry that will be displayed with out actually being in the model (you can see it but you can't select/move/delete etc. etc..).
Part of this feature of the API is a method that gets calle...
Hi,
i'm using java on a big amount of data.
[i try to simplify the problem as much as possible]
Actually i have a small class (Element) containing an int KEY and a double WEIGHT (with getters&setters).
I read a lot of these objects from a file and i have to get the best (most weight) M objects.
Actually i'm using a PriorityQueue wi...
Let's say you have two Controls, Alice and Bob, and you want to swap their position. By that I mean that after the swap:
If they are living in the same ControlCollection, Alice should have the index of Bob and vice versa.
If in different ControlCollections, Alice should have the same index as Bob, but be in Bobs ControlCollection and v...
I'm considering using Actors in a system to wrap some storage (could be a database, could be an in-memory collection). The reason I want to do this is because I don't want calls to the store to be blocking from the code that's calling it and I intend to push a high volume of messages through.
Could an actor's inbound message queue handl...
I'm a bit confused as to why this isn't working; I assume that because I'm adding the class and its not being added back into the collection I'm not sure.
Here it is on a jsbin http://jsbin.com/ayije although code is below also.
Either way I can only get the action to happen on an element once;
<html>
<head>
<script src="http...
I'm using the com.google.common.collect.ArrayListMultimap<K,V> collection to map Integers to Strings. The class provides a method called containsValue(Object value) which checks if the multimap contains the specified value for any key. Once I determine that is true, what's the best way to retrieve said key?
ArrayListMultimap<String, Int...
I have a function which returns a one-sided intersection of values between two input maps:
Map<Key, Value> mergeMaps(Map aKeys<CompositeKey, Key>,
Map <CompositeKey, Value> aValues) {
Map<Key, Value> myResult = Maps.newHashMap();
for (CompositeKey myKey : aKeys.keySet()) {
if (aValues.containsKey(myKey)) {
...
Say I have 2 parallel collections, eg: a list of people's names in a List<String> and a list of their age in a List<Int> in the same order (so that any given index in each collection refers to the same person).
I want to iterate through both collections at the same time and fetch the name and age of each person and do something with it....
How is the performance of ConcurrentHashMap compared to HashMap, especially .get() operation (I'm especially interested for the case of only few items, in the range between maybe 0-5000)?
Is there any reason not to use ConcurrentHashMap instead of HashMap?
(I know that null values aren't allowed)
Update
just to clarify, obviously the...
I am currently using a Hashtable to store a list of unique identifiers and associated data, all of which is read in from a file.
The length of this data file can very greatly, from 1 entry to several hundred thousand. I've noticed a significant slowdown in the speed of adding entries to the Hashtable once it gets past about 50,000 entr...
Possible Duplicate:
Which collection for storing unique strings?
I am currently using a Dictionary<string, bool> to store a list of unique identifiers. These identifiers do not need to have any data associated with them - I am just using the Dictionary to be able to quickly check for duplicates.
Since I only need keys, and no ...
I used a TreeSet with a self written Comparator. Now when I'm adding elements to the TreeSet and the Comparator's compare methods returns 0, it seems like the TreeSet contains only one of the Object with equal ranking.
I didn't see that this behaviour is documented in the javadocs. Maybe I miss something. Can you confirm this behaviour...
I want to write code that is decouple and clean, and I know that by programming to an interface instead of the implementation, my code will be more flexible and extensible. So, instead of writing methods like:
bool IsProductAvailable(ProductTypeA product);
I write methods like:
bool IsProductAvailable(IProduct product);
As lon...
Searching for the magic ParallelHashMap class
More succinctly, can you use multiple threads to speed up HashMap lookups? Are there any implementations out there that do this already?
In my project, we need to maintain a large map of objects in memory. We never modify the map after it is created, so the map is strictly read-only. Howeve...
I have an IQueryable object which is the result of view (using a data model in Visual Studio).
I want to apply an additional filter on the object, but I don't want it to go back to the database and run the query again with the additional where clause. The query takes several seconds to run so I'd like linq to simply filter the current ...
I would like to deep clone a List. for that we are having a method
SerializationUtils.clone ( object ) // apache commons method. Object shld be serializable
so now to clone my List i should convert that to serializable first. Is it possible to convert a List into Serializable list?
...
How, in a .NET, do you search a sorted collection for a key, and get the index, or if it doesn't exist, get the index of the next highest item?
For example there is a list that contains elements {1,5,8,10}. I search for 7. It doesn't exist, but the next highest key that does exist is 8 with an index of 2.
Example:
SortedList<int, int>...
I'd like to be able to conditionally replace a value in a ConcurrentHashMap. That is, given:
public class PriceTick {
final String instrumentId;
...
final long timestamp;
...
And a class (let's call it TickHolder) which owns a ConcurrentHashMap (let's just call it map).
I wish to be able to implement a conditional put m...