In the solution I have worked out to this question => General type conversion without risking Exceptions (See the edit at the bottom of the question), I need to cache a method for converting between two types.
So, given Type1 and Type2 I need to retrieve a method.
In the answer to this question => What is the best C# collection with tw...
On the very high level, I know that we need to "wrap" the priminitve data types, such as int and char, by using their respective wrapper classes to use them within Java collections. I would like to understand how Java collections work at the low level by asking: "why do we need to wrap primitive data types as objects to be able to use th...
I have the following object :
class Repeat{
private long startIndex;
private long endIndex;
private int length;
private float repetitions;
private float period;
private int errors;
private float percentOverlap;
public void setPercentOverlap(float percentOverlap) {
this.percentOverlap = percentOve...
I have a WPF form that shows a contact (Name, Address and State).
The GUI is bound to a CurrentContact object and they are stored in a List<Contact>.
I would like to add buttons to the bottom:
+-----+ +-----+ +-----+ +-----+
| << | | < | | > | | >> |
+-----+ +-----+ +-----+ +-----+
Meaning first, previous, next an...
I've been searching for the standard implementation of a doubly linked list in c# (so that I have a linked list I can iterate over backwards) and cannot find one. I feel like something so simple must have an implementation that I'm just missing.
If it does exist, for which version of c#/.net does it exist?
Reverse iteration in general ...
Scenario
I have a single base class and 2 (possibly 3) other classes that derive from that base class.
//Base Class
class RateInstrument
{
public string Ric { get; set; }
public string Tenor { get; set; }
public double Rate { get; set; }
public DateTime Date { get; set; }
public double Price { get; set; }
...
In Wintellect's PowerCollections, there's a GetValueElseAdd which works like this:
if ( collection.GetValueElseAdd( key, ref value))
{
// just added, value unmodified
}
Or
// factory method only gets called if the key is not present.
if ( collection.GetValueElseAdd( key, out value, () => thingFactory.CreateNew()))
{
// just a...
I have a class with some collections in them, and I would like to serialize instances of this class to XML without having to initialize the collections to be empty, and without having to implement IXmlSerializable. I don't care if it creates empty elements, or doesn't create the elements at all. Just that it works without having to ini...
Given a generic List I would need some kind of index (in the database sense) that would allow me fast retrieval. The keys for this index would not be unique, so I can't use a dictionary. Here's what I have in mind: Given a class Foo { P1, P2, P3 } that may have data like this
{ "aaa", 111, "yes" }
{ "aaa", 112, "no" }
{ "bbb", 111, "no"...
If I have a (reference - does it matter?) type MyType which does not override the Equals method, what heuristics will be used when determining if an ICollection<MyType> contains a given instance of the type?
What's the best way to use my own heuristics (e.g. check for the equality of the Id property value)?
...
I'd like to put unmodifiable wrappers around some of the Trove collections: I've checked the Trove documentation and I cannot seem to find an easy way to do it (I may have overlooked something obvious).
So as of now every time I need such an unmodifiable wrapper I'm extending the Trove collection (for example TIntLongHashMap) and delega...
I have a method that expects a Set parameter. I want to pass in an empty set, and I don't want any side effects on the Set.
I can do this with collections by passing in:
Collections.unmodifiableSet(Sets.newHashSet())
But I want to pass in:
ImmutableSet.of()
If I do the former a Set<Object> is created and I get "method not appli...
I have a data model involving Users and Awards, and joined by a user_awards table.
class User < ActiveRecord::Base
:has_many :user_awards
:has_many :awards, :through => :user_awards # awards the user has won
end
class Award < ActiveRecord::Base
:has_many :user_awards
:has_many :users, :through => :user_awards
end
I'd like th...
What are some good Java APIs for working with graphs (edges/nodes) as data structures?
Please add references to similar SO questions in comments to this wiki. Please edit the list in this wiki entry directly. Please add summary description of your added projects as answers (one project per answer).
JUNG Java Universal Network/Grap...
I have a List of structure.In the loop i am trying to modify the object's property,which is happening,but when i (Quick look in Visual studio)look into the list object ,the new value is not reflecting.Is it by virtue that the structure's object cannot be modified when in a collection?
I am using generics list with the struct as the type ...
I'm programing a game for Android. As an example, the game might involve bullets, enemies, gems etc. which need to be:
created and destroyed in the game world during gameplay e.g. a bullet is fire and then disappears when it hits a wall.
accessed a lot in sequence e.g. all updated in sequence, then all drawn in sequence.
Based on wh...
Suppose you have the following class:
class Car : IPainting
{
...
}
Then a function like this:
void AddCars(IEnumerable<Car> collection)
Then a code snippet like this:
Car bmw = new Car();
Car mercedes = new Car();
IPainting a = (IPainting) bmw;
IPainting b = (IPainting) mercedes;
IPainting[] paintings = new IPainting[] {a, b};...
1 of the presentation says "These methods are LAZY!"
Iterable transform(Iterable, Function)*
Iterable filter(Iterable, Predicate)*
T find(Iterable<T>, Predicate)
Iterable concat(Iterable<Iterable>)
Iterable cycle(Iterable)
T getOnlyElement(Iterable<T>)
Iterable<T> reverse(List<T>)
Can someone help me understand what they mean by this,...
[pre-able]
In my www.twipler.com project I want to allow people to link Twitter accounts. This will be achieved by having them login, selecting "link account" and then logging in again. This will effectively give me UserId-1 and UserId-2. Now I want to allow the user to login with either UserId-1 or UserId-2 credentials and then retreive...
Lot of times I have to create a Dictionary<KeyType, List<ValueType>>
Before I can start using the dictionary I have to first verify that List has been created for that key.
//Can i remove these two lines?
if(!dict.ContainsKey(key))
dict[key]= new List<ValueType>;
//now use the key
dict[key].Add(value);
I know its only "2 lines"...