I'm investigating performance on an operation. I'm iterating a subset of items from a collection. I filter this collection using a Linq query. It basically looks like this:
var filteredItems = items.Where(x => x.PropertyToFilterOn == filterValue);
foreach (var filteredItem in filteredItems)
{
// do something to the filtered item
}
...
In Python, How can one subtract two non-unique, unordered lists? Say we have a = [0,1,2,1,0] and b = [0, 1, 1] I'd like to do something like c = a - b and have c be [2, 0] or [0, 2] order doesn't matter to me. This should throw an exception if a does not contain all elements in b.
Note this is different from sets! I'm not interested in ...
Related:
http://stackoverflow.com/questions/1391918/does-java-have-a-linkedconcurrenthashmap-data-structure
I am looking for a collection class to hold references to event listeners.
Ideally I would like the collection to have the following properties (in order of priority):
Maintains insertion order. The earlier listeners may can...
I have a Page class and a PageCollection class in a 3d party ORM framework. I can fill the PageCollection based on parameters (pageid, parentid, url etc..) (SQL query). But I need the data multiple times around the ASP.NET MVC website (Sitemap, Authentication), so I chose to load all pages 1 time and reference that (global) collection.
...
I have a Set of keys and a List of key/value pairs. The values are of the form Long,BigInteger.
// key/values pairs: Long,BigInteger
List<Object[]> values;
// id list that corresponds to the keys for the list above
Set<Long> ids;
If any member of the key Set does not exist as a key in the key/value list, I want to add it to the list w...
I'm trying to map a collection of enum values with Fluent NHibernate.
IList<EnumType> lst;
I can't find any documentation about it but I'm quite sure it should be possible.
I had no problem at all with mapping a collection of Entities.
Thanks,
Leonardo
...
Is static initialized unmodifiableCollection.get guaranteed immutable?
For:
static final Map FOO =
Collections.unmodifiableMap(new HashMap());
Can multiple threads use method get and not run into problems?
Even through items in FOO cannot be added/removed, what's stopping the get method from manipulating FOO's internal state for ca...
Is it good practice to store sub-collections of item X inside a parent collection of item X for caching 'filter-queries' which are performed on the parent collection? (They won't be used together (as in color AND type).) Or is it also ok to just Loop over the collection and return the correct entities in a temporary collection?
Class It...
Java code:
Transformer TRANSFORM_TO_INTEGER = new Transformer() {
public Object transform(Object input) {
Integer i = new Integer((String) input);
return i;
}
};
String begin = "1,2,3,4,5";
List strList = Arrays.asList(StringUtils.split(begin, ","));
CollectionUtils.transform(strList, TRANSFORM_TO_INTEGER);
Th...
I used to use List.h to work with lists in C++, but are there any similar libraries in .Net ? Becouse I can't use List.h for managed types.
...
What's the most efficient way to get a first free spot from sorted query returning int collection ?
eg.: {1,2,3,4,6} | result.: 5
At the moment I am using foreach and counter that compares current value from sorted quety.ToList()
which takes about 600ms on 100 000 records.
...
Is there a C# class that provides map with weak keys or/and weak values?
Or at least WeakHashMap like functionality.
...
I'm looking at the static method
Collections.synchronizedList(List<T> list)
Javadoc says
It is imperative that the user manually synchronize on the returned list when iterating over it...
What's the purpose of creating a synchronized list if I still have to manually synchronize it?
...
This is a bit of a long question, but I've made it as terse as possible, so please bear with me. It looks to me like a bug in the XmlSerializer class but before I file it with Microsoft I'd like to see if there's anything I've missed, which is entirely possible.
I'm attempting to generate the following XML as a representative case, whic...
Why is there the method iterator() defined on the interface java.util.Collection when it already extends java.util.Iterable which has this very method defined.
I'm thinking some sort of backward compatability or an opportunity to write some JavaDoc on the method at the collection level.
Any other ideas?
...
A little question regarding performance in a Java web app.
Let's assume I have a List<Rubrique> listRubriques with ten Rubrique objects.
A Rubrique contains one list of products (List<product> listProducts) and one list of clients (List<Client> listClients).
What exactly happens in memory if I do this:
listRubriques.clear(); listRub...
How do I test a generic dictionary object to see whether it is empty? I want to run some code as follows:
while (reportGraphs.MoveNext())
{
reportGraph = (ReportGraph)reportGraphs.Current.Value;
report.ContainsGraphs = true;
break;
}
The reportGraph object is of type System.Collections.Generic.Dictionary
When running this...
My need is to have items in kind of Collections.Generic.Dictionary where I can get a struct by it's id as a key. Then I have need to fetch many structs, say 1% or less of all items, by another field. Like a cursor by an non-unique index. With Dictionary I have to browse through all the values and check which has the correct value for tha...
I have been reading Nhibernate in Action, but the section on mapping polymorphic collections is a little too short on how to do this.
I have the following code
[Class]
[Discriminator(Column="MachineType",TypeType=typeof(string))]
public abstract class Machine
{
[Property]
public string Name{get;set;}
}
[Subclass(DiscriminatorValue...
I have a model class that stores keys and values:
public class KeyValue {
private Object key;
private String value;
KeyValue () {
}
KeyValue (Object key, String value) {
this.key=key;
this.value=value;
}
public Object getKey() {
return this.key;
}
public void setKey(Object ...