I return empty collections vs. null whenever possible. I switch between two methods for doing so using java.util.Collections:
return Collections.EMPTY_LIST;
return Collections.emptyList();
where emptyList() is supposed to be type-safe. But I recently discovered:
return Collections.<ComplexObject> emptyList();
return Collections.<C...
Hi,
I've been working with subsonic for a few weeks now, and it is working really well. However, I've just run into an issue with child objects with additional partial properties. Some of it is probably me just not understanding the .Net object lifecycle.
I have an object - search. This has a few properties like permissions and stuff, ...
I've just imported some java source into 'Enterprise Architect', e.g:
class Truck
{
BumperSticker bumperSticker;
Vector<Wheel> wheels;
}
It's added the first member as an association, and it hasn't added the second as a relationship at all.
How do I get it to instead, add them both as aggregations, the second with a multiplicity ...
Hello,
I have written the Dijkstra's algorithm many times in C++ - I need there set or priotity_queue, both give me possibility to add an element and find the least one (using specified comparator). Now, I've got a problem when trying to write Dijkstra in C# - is there any structure which could be useful for me? I need adding and findin...
Lets say I've a Team class which contains 0 or more Players.
The Player class is easy:
public class Player
{
public long Id { get; set; }
public string Name { get; set; }
public Team Team { get; set; }
}
But whats the best to define the Team class?
Option 1
public class Team
{
public long Id { get; set; }
public...
But some of the callers is the Dictionary's TryGetValue and ContainsKey and so require the result of the method to be a Dictionary, how can I convert the IEnumerable<KeyValuePair<string, ArrayList>> into a Dictionary<string, ArrayList> so that I can use TryGetValue ?
I've a method which at present returns an IEnumerable<KeyValuePair<str...
class UserDatastore : IUserDatastore
{
...
public IUser this[Guid userId]
{
get
{
User user = (from u in _dataContext.Users
where u.Id == userId
select u).FirstOrDefault();
return user;
}
}
...
}
One of the d...
How to remove duplicates from a StringCollection in c#? I was looking for a more efficient approach. StringCollection is returned from an API.
...
I am trying to implement a new class inherited from List<string>, to load the contents from a text file to the items.
using System.Collections.Generic;
using System.IO;
using System.Linq;
public class ListExt : List<string>
{
string baseDirectory;
public void LoadFromFile(string FileName)
{
//does not work because ...
Let's assume we have two collections:
List<double> values
List<SomePoint> points
where SomePoint is a type containing three coordinates of the point:
SomePoint
{
double X;
double Y;
double Z;
}
Now, I would like to perform the intersection between these two collections to find out for which points in points the z coordinate is e...
I've got a Customer object with a Collection of CustomerContacts
IEnumerable<CustomerContact> Contacts { get; set; }
In some other code I'm using Reflection and have the PropertyInfo of Contacts property
var contacts = propertyInfo.GetValue(customerObject, null);
I know contacts has at least one object in it, but how do I get it ou...
I was surprised by the fact that Map<?,?> is not a Collection<?>.
I thought it'd make a LOT of sense if it was declared as such:
public interface Map<K,V> extends Collection<Map.Entry<K,V>>
After all, a Map<K,V> is a collection of Map.Entry<K,V>, isn't it?
So is there a good reason why it's not implemented as such?
Thanks to Clet...
Hi,
Anyone know if there exists any IoC container that can handle this:
Given:
ISomeInterfce<T> where T : Entity
Impl1 : ISomeInterfce<Entity1>
Impl2 : ISomeInterfce<Entity1>
Impl3 : ISomeInterfce<Entity2>
Impl4 : ISomeInterfce<Entity2>
I want to be able to auto wire my system and be able to resolve like this
IoC.ResolveAll(typ...
this is simple I know, but i don't have internet access and this netcafes keyboard sucks, so if someone can answer this question please.
what would be the class ? just give me a kick in the right direction. there is simple arraylist object that I want to write and read to/ from file.
thanks
...
I need a collection that behaves something like C++ multimap, but I also need to be able to get elements by a range of keys.
...
I'm getting a compiler error for this line:
Collections.sort(terms, new QuerySorter_TFmaxIDF(myInteger));
My customized Comparator is pretty basic; here's the signature and constructor:
public class QuerySorter_TFmaxIDF implements Comparator<Term>{
private int numberOfDocs;
QuerySorter_TFmaxIDF(int n){
super();
numberOfDocs ...
I'm looking for as simple way to create an identity set. I just want to be able to keep track of whether or not I've "seen" a particular object while traversing a graph.
I can't use a regular Set because Set uses "==" (the equals method in Scala) to compare elements. What I want is a Set that uses "eq."
Is there any way to create a S...
How to create sorted map in scala (mutable/immutable)?
...
How to compare two maps by their values? I have two maps containing equal values and want to compare them by their values. Here is an example:
Map a = new HashMap();
a.put("foo", "bar"+"bar");
a.put("zoo", "bar"+"bar");
Map b = new HashMap();
b.put(new String("foo"), "bar"+"bar");
b.put(new String("zoo"), "bar"+...
Hello,
I have been trying to return a collection from a property within a class to a routine in a normal module. The issue I am experiencing is that the collection is getting populated correctly within the property in the class (FetchAll) but when I pass the collection back to the module (Test) all the entries are populated with the las...