I need to set the value of an element in my sortedDictionary, accessed by index.
I.e.
sortedDictionary.Values[index] = value; // compile error
Note that the following is incorrect because it's accessed by key, not index.
sortedDictionary[index] = value; // incorrect
I came up with the following solution, but intuition tells me it'...
I have a class like this
public class HistoryEntry
{
DateTime Date{ get; protected set; }
HistoryType EntryType { get; protected set; }
}
public enum HistoryType
{
Cancelled,
Cleared,
Redeemed,
Refunded
}
I have an unordered list of these History Entries, and I do Exists statements to see if an entry exists in...
I'm trying to use LINQ To Objects to create a query that will give me files, indexed by filename with a value mapping to their binary data as byte[].
However I can't find a 'neat' way to do this. I'm hoping to get something like a Dictionary<T,K> output.
Here's what I have so far. Example delimFileNames="1.jpg|2.jpg"
//Extract filenam...
I have been refactoring throwaway code which I wrote some years ago in a FORTRAN-like style. Most of the code is now much more organized and readable. However the heart of the algorithm (which is performance-critical) uses 1- and 2-dimensional Java arrays and is typified by:
for (int j = 1; j < len[1]+1; j++) {
int jj = (con...
I have a number of collections of classes which I need to refactor into new classes. I'm using Java with either Eclipse or Netbeans. Currently I create the new class FooList with a delegate List<Foo> and then follow all the places where the code fails to compile. Is there a way to do this without breaking the code (and preferably a singl...
A component I am working on uses a TCollection to hold links to other components. When the items are edited in the designer their labels look something like this:
0 - TComponentLink
1 - TComponentLink
2 - TComponentLink
3 - TComponentLink
How do I add meaningful labels (the name of the linked component perhaps)? e.g.
0 - UserList
1 -...
This works:
<hibernate-mapping>
<class name="Train" table="Trains">
<id column="id" name="id" type="java.lang.String" length="4">
<generator class="assigned" />
</id>
<set name="trips" cascade="all">
<key column="trainId"/>
<one-to-many class="Trip"/>
</set>
<...
So. Um. The Blackberry JDE does not include java.util.ArrayList, even though it knows about java.util? What's up with that? Is there an equivalent class for BB? I don't want to use an Array, really, because I have an unknown number of objects I'm dealing with. why does the Blackberry JDE leave so much out?
-Jenny
...
Easiest way to convert a List to a Set? - In Java
...
I have two numbers and I want to use them together as a key in a Map. Currently, I'm concatenating their string representations. For example, suppose the key numbers are 4 and 12. I use:
String key = 4 + "," + 12;
The map is declared as Map<String, Object>.
I think this is so bad! I like to use something other than a String as the ke...
Ok. Here is a problem. This is my collection : {2,3,4,2,3,5}. Let's assume that it is a List for now. I would like to search this collection for all matches of '2'. I would like indexes of the same. I know that there are indexOf() and lastIndexOf() methods in List and Arrays.binarySearch(). However, all of them return one element indicat...
If I create a new form called myForm, the top of myForm.h looks like this:
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections; //<<<< THIS ONE
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
None of these are even ...
I need to define a class with an internal collection object to hold different types of values(such as string, int, float, DateTime, and bool) by a string key. I could use Hashtable since it is not strongly typed collection class, while the Dictionary is used for strongly typed items (I could use object for Dictionary even though).
Here...
When serializing a custom generic collection to Xml how do I add an attribute to the generated collection element.
Currently I have:
<RootObject>
<Id>1</Id>
<Items>
<MyCollectionItem/>
<MyCollectionItem/>
</Items>
</RootObject>
What I need is:
<RootObject>
<Id>1</Id>
<Items Name="My collection name">
<MyCollec...
I'm making a little file splitter-joiner, and I've already got the splitting process done. Now I need to complete the joiner.
I have this method:
public static void juntarArchivo(string[] Cortes, string CarpetaDestino)
{
string Nombre = ExtraerNombre(Cortes[0]);
int CantidadDeCortes = Cortes.Length;
...
I have a pretty simple question. While I am fairly new to Objective-C, I have gotten pretty comfortable with the language and the memory management model.
I understand ownership pretty well and the notion of explicit and implicit. I also understand that when you add anything to a collection, it takes ownership of the keys and values a...
I'm wondering if there is an IList<T> implementation that's backed by a hash like HashSet<T> but offers indexed access?
To be clear, I'm not concerned on how to implement one, just wondering if anyone knows if it's already available.
...
I was looking for a bidirectional map implementation in Java, and stumbled upon these two libraries:
Apache Commons Collections
Google Collections
Both are free, have the bidirectional map implementation that I was looking for (BidiMap in Apache, BiMap in Google), are amazingly nearly the same size (Apache 493 kB, Google 499 kB) and ...
I have a need for a fairly specialised collection .NET, and I don't think that the BCL can help me, but I thought I'd throw it out there for if anyone knew of something similar.
Basically, my requirements are thus:
I have a list of pairs of values, such as: (3, 10), (5, 10), (3, 7), (5, 5)
Order is important, ie. (3, 10) != (10, 3)
Du...
I've been a Java programmer almost exclusively for the past 8 years or so, and recently I've been playing with C++ again. Here's an issue that I've come up against with regards to iterators in C++ STL and Java.
In Java, you can write a method that takes an iterator like this:
void someMethod(Iterator<String> data) {
// ...
}
You ...