I have a custom class Foo with properties A and B. I want to display it in a databinding control.
I have created a class Foos : BindingList<Foo> .
In order to update some internal properties of the Foos class I need to be notified of property changes (I can handle insertions, removals etc.) on the items in the list. How would you imple...
I have a Silverlight project where the main objects are just a bunch of nodes that are joined to each other. A parent node can have many children.
I want to be able to bind the nodes to an itemscontrol or similar and so was wondering how to best structure the parent child relationship.
Is it OK to create a flat top level list of all n...
I have a
List<Cat>
sorted by the cats' birthdays. Is there an efficient Java Collections way of finding all the cats that were born on January 24th, 1983? Or, what is a good approach in general?
...
I have a custom made class called Graph in which I use adjacency lists. To be more specific, I have an array of hash maps where each hash map contains all that node's neighbors as edges. The key is the end node and the value is an Edge object.
Now i want to make this Graph class implement Iterable. Is there a way of merging all those h...
Using Java, assuming v1.6.
I have a collection where the unique index is a string and the non-unique value is an int.
I need to perform thousands of lookups against this collection as fast as possible.
I currently am using a HashMap<String, Integer> but I am worried that the boxing/unboxing of the Integer to int is making this slower.
...
Hi,
I have a WPF ListView bound to a CollectionViewSource. The source of that is bound to a property, which can change if the user selects an option.
When the list view source is updated due to a property changed event, everything updates correctly, but the view is not refreshed to take into account any changes in the CollectionViewSou...
I am looking for best practices for creating collections made from anonymous types.
There are several approaches - this one and most answers on this thread assume that the whole anonymous collection can be constructed in one statement.
As anonymous types are usually used to replace classes that are to be used to store temporary (as put...
I'm writing a lazy list to retrieve items from a database with a given criteria and a given paging (start index and number of items desired).
At the instantiation of the list I count the total number of items in the mapped table, so that I have an initial size of the list (initial, because the list permits the addition and removal of it...
In Java, Is there an object that acts like a Map for storing and accessing key/value pairs, but can return an ordered list of keys and an ordered list of values, such that the key and value lists are in the same order?
So as explanation-by-code, I'm looking for something that behaves like my fictitious OrderedMap:
OrderedMap om = new O...
I have an Iterator[Option[T]] and I want to get an Iterator[T] for those Options where T isDefined. There must be a better way than this:
it filter { _ isDefined} map { _ get }
I would have thought that it was possible in one construct... Anybody any ideas?
...
Hi,
The setup:
class Item
{
private int _value;
public Item()
{
_value = 0;
}
public int Value { get { return _value; } set { _value = value; } }
}
class ItemCollection : Collection<Item>
{
private string _name;
public ItemCollection()
{
_name = string.Empty;
}
public string ...
Are setters necessary for Collection Type Properties
//Type 1
class Company
{
private IList<Customer> customers;
public IList<Customer> Customers
{
get { return customers; }
set { customers = value; }
}
}
//Type 2
class Company
{
private readonly IList<Customer> customers = new List<Custo...
What is the most suitable container just for strings holding in some array with non-predetermined upper boundary, which length is unknown on it's creation.
For simple code like:
Foo list = new Foo(); // size in unknown
for()/foreach()/do()/while() // any loop
{
list.Add(string);
}
Is it StringCollection as optimized Collection for ...
I have two listboxes one with all the projects and one with only active projects.
I have one observablecollection with all my projects in it bound to the listbox with all projects. What do I bind to the other listbox? Do I need to create a new collection and sort out the active ones. And when I add a new active project I need to add to ...
What is the equivalent Scala constructor (to create an immutable HashSet) to the Java:
new HashSet<T>(c)
where c is of type Collection<? extends T>. All I can find in the HashSet Object is apply
...
If I have a collection c of type T and there is a property p on T (of type P, say), what is the best way to do a map-by-extracting-key?
val c: Collection[T]
val m: Map[P, T]
One way is the following:
m = new HashMap[P, T]
c foreach { t => m add (t.getP, t) }
But now I need a mutable map. Is there a better way of doing this so that ...
Related to this question, how do convert a Java collection (java.util.List say) into a scala collection List?
EDIT; what I am actually trying to do is convert a Java API call to Spring's SimpleJdbcTemplate, which returns a java.util.List<T>, into a scala immutable HashSet. So for example:
val l: java.util.List[String] = javaApi.query( ...
Coming from a Java background, I'm used to the common practice of dealing with collections: obviously there would be exceptions but usually code would look like:
public class MyClass {
private Set<String> mySet;
public void init() {
Set<String> s = new LinkedHashSet<String>();
s.add("Hello");
s.add("World");
mySet ...
I've been trying to extend the ArrayList class without much success. I want to extend it, and be able to parameterize it.
So normally you have something like
ArrayList<SomeObject> list = new ArrayList<SomeObject>();
I want
MyList<SomeObject> list = new MyList<SomeObject>();
Simply extending ArrayList doesn't work.
public class M...
EDIT: Re-written this question based on original answer
The scala.collection.immutable.Set class is not covariant in its type parameter. Why is this?
import scala.collection.immutable._
def foo(s: Set[CharSequence]): Unit = {
println(s)
}
def bar(): Unit = {
val s: Set[String] = Set("Hello", "World");
foo(s); //DOES NOT CO...