I have a collection object that implements IList. Inside the collection I have used a List to collect the items.
Inside the PropertyGrid (at runtime), it binds properly and the Collection Editor opens. I can edit, and I can add items properly and I can catch these methods when they are used in the collection class.
However, if you try t...
Is there any reason to expose an internal collection as a ReadOnlyCollection rather than an IEnumerable if the calling code only iterates over the collection?
class Bar
{
private ICollection<Foo> foos;
// Which one is to be preferred?
public IEnumerable<Foo> Foos { ... }
public ReadOnlyCollection<Foo> Foos { ... }
}
/...
I am returning a List from my WCF method. In my client code, it's return type shows as MyObject[]. I have to either use MyObject[], or IList, or IEnumerable...
WCFClient myClient = new WCFClient();
MyObject[] list = myClient.GetMyStuff();
or
IList<MyObject> list = myClient.GetMyStuff();
or
IEnumerable<MyObject> list = my...
I want to use a collection initializer for the next bit of code:
public Dictionary<int, string> GetNames()
{
Dictionary<int, string> names = new Dictionary<int, string>();
names.Add(1, "Adam");
names.Add(2, "Bart");
names.Add(3, "Charlie");
return names;
}
So typically it should be something like:
return new Dicti...
I had another developer ask why I use List all over the place ... and I thought about it for a minute ... and couldn't come up with a definitive answer.
If you inherit from the collection base class to extend instead of using List(Of T) - what advantages do you get? Or - what don't you get with List?
...
I'm writing some Scala code which uses the Apache POI API. I would like to Iterate over the Rows contained in the java.util.Iterator that I get from the Sheet class. I would like to use the Iterator in a for each style loop, so I have been trying to convert it to a native Scala collection but will no luck.
I have looked at the Scala Wra...
I have a DAL that makes calls to my Entity Framework Model. The calls return things like IOrderedQueryable and IQueryable objects. Should I convert them to something more universal in my DAL, such as List? But I assume that if I don't need to enumerate through the entire collection, this could be wasteful... So whats the best approac...
What is the best way to convert from a generic IEnumerable object to an array of the same type? The current solution I have looks like the following:
IEnumerable<string> foo = getFoo();
string[] bar = new List<string>(foo).ToArray();
The transfer through a List<T> seems unneccesary, but I haven't been able to find a better way to do ...
Hi,
I had an issue in building the resultset using java. Here it goes...
I am storing a collection object which is organized as row wise taken from a resultset object and putting the collection object(which is stored as vector/array list) in cache and trying to retrieve the same collection object.
Here i need to build back the resultse...
Hi,
I have asked this question on more than one forums and it seems no one would even want to take a crak at it.
My problem is simple and i would guess everyone has run into it when using LINQ to SQL.
If your have a LINQ object called: Person and you would like to poulate a list box based on all of the people you have in your DB the ta...
How can I add an opaque type to a collection in cocoa?
I get a compiler warning for this (obviously, because opaque types are not objects):
CGColorSpaceRef colorSpace;
NSArray *myArray = [NSArray arrayWithObject:colorSpace];
...
I have an ArrayList a collection class of java as follows.
ArrayList<String>animals = new ArrayList<String>();
animals.add("bat");
animals.add("owl");
animals.add("bat");
animals.add("bat");
As you can see the animals ArrayList consists of 3 bat elements and one owl element. I was wondering if there is any API in collection framework ...
I have a Collection, and I want to remove all items that have a certain property set to true. I use a filterFunction to accomplish this. My question is, how can I add new items to the Collection that have that property set to true? The filterFunction is still applied, and the item is not added....
Do I have to iterate through the entire...
Is there a way that you can get a collection of all of the Models in your Rails app?
Basically, can I do the likes of: -
Models.each do |model|
puts model.class.name
end
Thanks in advance.
...
I have a Dictionary which I'd like to use like an IN clause within a SQL query.
I have a Linq-To-SQL query where I would like to use this Dictionary's Keys to check fields in the rows for the query.
E.g.
bool result = DataContext.Table.Any(res => MyDictionary.ContainsKey(res.field1));
In effect this is similar to
exists(sel...
This is a compiler error (slightly changed for readability).
This one always puzzled me. FxCop tells that this is a bad thing to return List and classes that are\derived from Collection<T> should be preferrable as return types.
Also, FxCop says that it is OK to use List<T> for internal data storage\manipulation.
Ok, I get it, but what ...
The Problem:
I need to receive different types of content from a number of different sources normalize them and then make them persistent through JDO.
Naive Solution?:
Create and listen on a specific port for each data type.
OR
Do a bunch of complicated parsing
A Seemingly Ideal Solution:
Have custom URL types Ie. FOO://myhost.tl...
I have a scenario where I have multiple threads adding to a queue and multiple threads reading from the same queue. If the queue reaches a specific size all threads that are filling the queue will be blocked on add until an item is removed from the queue.
The solution below is what I am using right now and my question is: How can this b...
Basically I am storing millions of vector3 values in a list. But right now the vector3s are defined like so:
[5,6,7]
which I believe is a list. The values will not be modified nor I need any vector3 functionality.
Is this the most performant way to do this?
...
Given:
Object nestKey;
Object nestedKey;
Object nestedValue;
Map<T,Map<T,T>> nest;
Map<T,T> nested;
How is a mapping added to nested where:
nest.containsKey(nestKey) == true;
?
Or is there an existing library of collections that would be more effective?
...