collections

three item HashMap without internal iteration

What is the best way to implement a three item hashMap? For example, I would like to use a regular String key , but have it map to two different objects. The idea is like having a list of lists, except that the first item is a key. I am trying to avoid iterating through the list ( so the behavior is like a hashmap ). Would you agree the...

How to insert a "Pair" or n-size into a list collection instead of composing HashMaps?

So, I have a situation where I need to pass in three values into a serial BlockingQueue queue: (SelectableChannel, ComponentSocketBasis, Integer). They don't actually need to be hash mapped at all, and to use a HashMap is ridiculous as there will always be only one key for each entry; it'd be fine if they were just in some sort of o...

How to present a Collection of (View)Models in a ViewModel

Hi. I have a question regarding the MVVM design for C#/WPF. I've had a look at several demo applications, but they didn't really handle my problem. My application consists of objects that contain other objects. Much like in a parent - children relationship. My question now is: does the children attribute have to be a ViewModel and ...

Sequence comparison in java.

I'm looking for a standard algorithm/code (Java) which compares two integer lists (old and new) and gives a third result list which provides actions to convert the 'old' list into the 'new' list. For example: old-> 1, 2, 3, 4 new-> 9, 2, 3, 6, 4 so the result should be something like: 1-, 9+, 2, 3, 4-, 6+, 4+ Here, the suffix: ...

Nested generic collections: How to implement reference from item to container?

Hi! While implementing a design using nested generic collections, I stumbled across those limitations apparently caused by C#'s invariant Generics: Cannot convert from 'Collection<subtype of T> to 'Collection<T>' That means, the following will not work, apparently due to the invariance of Generics: class Outer<TInner, TInnerItem> wh...

stack collection missing shift and unshift in C# 2.0

Bizarrely the stack collection seems to be missing the rather basic shift and unshift methods* and I'm working in 2.0 so I can't just extend them. Is there any reasonable technique or alternative collection class to get these methods available? I need push and pop as well. Edit: looks like the collection I want is indeed a deque which ...

Are there strongly-typed collections in Objective-C?

I'm new to Mac/iPhone programming and Objective-C. In C# and Java we have "generics", collection classes whose members can only be of the type declared. For example, in C# Dictionary<int, MyCustomObject> can only contain keys that are integers and values that are of type MyCustomObject. Does a similar mechanism exist in Objective-C...

ASP FileSystemObject collection cannot be accessed by index

Am I going mad? I cannot find a way to get hold of the first file in a folder with the FileSystemObject (classic ASP). With most collections you'd think the index 0 or 1 might work, but IIS says "Invalid procedure call or argument". Neither of these last 2 lines work: Set oFileScripting = CreateObject("Scripting.FileSystemObject") Set ...

Iterate through a ControlCollection from a CreateUserWizardStep

Hello, I am attempting to iterate through a ControlCollection in the CreatedUser event of my CreateUserWizardStep. I have a ContentTemplate that contains a table full of checkboxes that I am using to gather a user's availability during the week. For the sake of brevity I will paste my code on pastebin. Here is a link to the .aspx page....

Generic collection loading from the generic type

I have the following code, where i am trying to create a generic collection for the objects in my DAL (just an exercise, not actually production code). My problem is that i want to use the type passed in's Read method (which is part of an interface that the classes implement). I cannot create a new T so i dont have an instance of the...

Asymptotic complexity of .NET collection classes

Are there any resources about the asymptotic complexity (big-O and the rest) of methods of .NET collection classes (Dictionary<K,V>, List<T> etc...)? I know that the C5 library's documentation includes some information about it (example), but I'm interested in standard .NET collections too... (and PowerCollections' information would als...

go beyond Integer.MAX_VALUE constraints in Java

Setting aside the heap's capacity, are there ways to go beyond Integer.MAX_VALUE constraints in Java? Examples are: Collections limit themselves to Integer.MAX_VALUE. StringBuilder / StringBuffer limit themselves to Integer.MAX_VALUE. ...

Java ArrayList and HashMap on-the-fly

Can someone please provide an example of creating a Java ArrayList and HashMap on the fly? So instead of doing an add() or put(), actually supplying the seed data for the array/hash at the class instantiation? To provide an example, something similar to PHP for instance: $array = array (3, 1, 2); $assoc_array = array( 'key' => 'value'...

How to return a readonly copy of a collection

I have a class that contains a collection. I want to provided a method or property that returns the contents of the collection. It's ok if calling classes can modify the individual objects but I do not want them adding or removing object from the actual collection. I have been copying all the objects to a new list, but now I'm thinking t...

What is the known performance difference between a Microsoft.VisualBasic.Collection and a .NET System.Collections.Generic.Dictionary(Of TKey, TValue)?

I'm working on a fairly large project for a trading company in Philadelphia. The company utilizes automated trading algorithms which process streaming quotes and send out quotes for hundreds of products dozens of times per second. Obviously, performance is a significant concern. (Which makes me question why we're using VB.NET, but that's...

What are the reasons why Map.get(Object key) is not (fully) generic

What are the reasons behind the decision to not have a fully generic get method in the interface of java.util.Map<K,V>. To clarify the question, the signature of the method is V get(Object key) instead of V get(K key) and I'm wondering why (same thing for remove, containsKey, containsValue). ...

How to make a new List in Java

We create a Set as Set myset = new HashSet() How do we create a List in Java? ...

Why does the java.util.Set<V> interface not provide a get(Object o) method?

I understand that only one instance of any object according to .equals() is allowed in a Set and that you shouldn't "need to" get an object from the Set if you already have an equivalent object, but I would still like to have a .get() method that returns the actual instance of the object in the Set (or null) given an equivalent object as...

Using NHibernate and not referencing its assembly in the client application

Hi, We have a multi-tiered application using CSLA Business Objects and NHibernate ORM. In our Business Objects, we hold our collection data members as ICollection<T>, and in our object mapping files we define them as <set>s. Since NHibernate uses its own concrete types to fetch these collections, we have a problem when these collection...

Generic Test harness for java.util.Map?

I have a custom implementation of the Map interface which does some fancy stuff, like lazy evaluation of functions. the implementation should appear immutable after construction from outside (e.g. no put() and putAll() methods are supported) I it looks like it works in the most basic conditions. Since it is quite complex, i am sure ther...