collections

IList<Item> Collection Class accessing database

Hi, I have a database with Users. Users have Items. These Items can change actively. How do you access the items in a collection type format? For the user, I fill all the user properties at the time of instantiation. If I load the user's items at the time of the instantiation, and the items change, they will have old data. I was think...

Multiple indexes for a Java Collection - most basic solution?

Hi, I'm looking for the most basic solution to create multiple indexes on a Java Collection. Required functionality: When a Value is removed, all index entries associated with that value must be removed. Index lookup must be faster than linear search (at least as fast as a TreeMap). Side conditions: No dependencies on large (like...

C Language Standard Collections Where Are They?

I have committed to learning C now, I'm good with Python/PHP/Bash but I've decided I'm limited by not being fluent in C. However I cannot imagine working in a language without lists and hashes, maybe I'm just jumping a gun, but surely there are 'standard' collection libraries. I do not see any in the GNU standard lib though, any sugges...

storing primitive values in a java collection?

Hi, Java collections only stores objects not primitive types but we can store using wrapper classes.Why this constrain? Thx ...

C#: What is the best collection class to store very similar string items for efficient serialization to a file

Hi, I would like to store a list of entityIDs of outlook emails to a file. The entityIDs are strings like: "000000005F776F08B736B442BCF7B6A7060B509A64002000" "000000005F776F08B736B442BCF7B6A7060B509A84002000" "000000005F776F08B736B442BCF7B6A7060B509AA4002000" as you can notice, the strings are very similar. I would like to save these ...

The Efficient way to sort a collection of Objects

Hi, I have a requirement to sort a collection of objects, They are shown on a web page in tabular format. My sorted collection is created like TreeSet<MyObject> objs= new TreeSet<MyObject>(); Currently MyObject is implementing Comparable interface to provide sorting. In the compareTo method object is checked against the date of cre...

Map equality using Hamcrest

Hello all, I'd like to use hamcrest to assert that two maps are equal, i.e. they have the same set of keys pointing to the same values. My current best guess is: assertThat( affA.entrySet(), hasItems( affB.entrySet() ); which gives: The method assertThat(T, Matcher) in the type Assert is not applicable for the arguments (Set>, M...

Performance for myCollection.Add() vs. myCollection["key"]

When dealing with a collection of key/value pairs is there any difference between using its Add() method and directly assigning it? For example, a HtmlGenericControl will have an Attributes Collection: var anchor = new HtmlGenericControl("a"); // These both work: anchor.Attributes.Add("class", "xyz"); anchor.Attributes["class"] = "xyz...

ActionScript/Flex ArrayCollection of Number objects to Java Collection<Long> using BlazeDS

Hello, I am using Flex 3 and make a call through a RemoteObject to a Java 1.6 method and exposed with BlazeDS and Spring 2.5.5 Integration over a SecureAMFChannel. The ActionScript is as follows (this code is an example of the real thing which is on a separate dev network); import com.adobe.cairngorm.business.ServiceLocator; import mx....

More nest Python nested dictionaries.

After reading http://stackoverflow.com/questions/635483/what-is-the-best-way-to-implement-nested-dictionaries-in-python why is it wrong to do: c = collections.defaultdict(collections.defaultdict(int)) in python? I would think this would work to produce {key:{key:1}} or am I thinking about it wrong? ...

Most appropriate exception for a collection not being initialised?

What is the most appropriate .Net exception type for when you have a class which must have its collection property initialised with at least one item? I'm thinking that it would be an ArgumentOutOfRangeException but is there something more appropriate based on a collection? ...

Interpolating Large Datasets On the Fly

Interpolating Large Datasets I have a large data set of about 0.5million records representing the exchange rate between the USD / GBP over the course of a given day. I have an application that wants to be able to graph this data or maybe a subset. For obvious reasons I do not want to plot 0.5 million points on my graph. What I need i...

Returning IEnumerable from an indexer, bad practice?

If I had a CarsDataStore representing a table something like: Cars -------------- Ford | Fiesta Ford | Escort Ford | Orion Fiat | Uno Fiat | Panda Then I could do IEnumerable<Cars> fords = CarsDataStore["Ford"]; Is this a bad idea? It's inconsistent with the other datastore objects in my api (which all have a single column PK index...

Better type safety in Java collections

In my java coding, I often end up with several Map<String,Map<String,foo>> or Map<String,List<String>> and then I have trouble remembering which String is which key. I comment the declaration with //Map<capabiltyId,Map<groupId,foo>> or //Map<groupId,List<capabilityId>, but it's not the greatest solution. If String wasn't final, I would...

I Need to Sort a Custom AutoCompleteStringCollection

I am writing a custom control that has a textbox. Inside the control I have a class that implements the AutoCompleteStringCollection so I can keep a Guid id with each string. This allows me to add autocomplete to a textbox but relate the selected text back to the database through the id. I want to add a property for forcing a selection f...

Datatype to use for collection of QT buttons

Hi Everyone, I am brand new to QT and need to develop the Mancala game. Since I'm brand new to the QT environment, my plan it to keep things very simple. I will be using the "Push Button" widget as pieces on the game. Since two players play this game, my idea is to have to arrays of buttons. One array for player 1 and the other for ...

Give me a practical use-case of Multi-set

I would like to know a few practical use-cases (if they are not related/tied to any programming language it will be better).I can associate Sets, Lists and Maps to practical use cases. For example if you wanted a glossary of a book where terms that you want are listed alphabetically and a location/page number is the value, you would us...

How to force a refresh of possibly cached value?

I have the following Repository: Public Class PageRepository Private Shared _pages As BLL.PageCollection Shared Function AllPages() As BLL.PageCollection If _pages Is Nothing Then _pages = new BLL.PageCollection(LOADALL) Return _pages End Function End Class I do all selects using LINQ on the PageRepository...

Retrieving the type of a Collection

So I have something like the following in Java: private List<SomeType>variable; // ....variable is instantiated as so ... variable = new ArrayList<SomeType>(); // there's also a getter public List<SomeType> getVariable() { /* code */ } What I would like to be able to do is figure out that variable is a collection of SomeType progra...

CollectionViewSource.GetDefaultView is not in Silverlight 3! What's the work-around?

The CollectionViewSource.GetDefaultView() method is not in Silverlight 3. In WPF I have this extension method: public static void SetActiveViewModel<ViewModelType>(this ViewModelBase viewModel, ViewModelType collectionItem, ObservableCollection<ViewModelType> collection) where ViewModelType : ViewModelBase { Debug.Assert(col...