The signature of TraversableLike.flatMap is as follows:
def flatMap[B, Th](f : (A) => Traversable[B])(implicit bf : CanBuildFrom[Repr, B, Th]) : Th
The signature of GenericTraversableTemplate.flatten is:
def flatten[B](implicit asTraversable : (A) => Traversable[B]) : CC[B]
Why is the latter method (which seems to me to differ from...
Beginner's question: How to implement a generic list List<Item> returning items with a property named Data but returning different types for different subclasses? I started building the following hierarchy, but that does not lead to the goal.
abstract class Item
abstract class ItemGeneric<TData> : Item
class ItemText : ItemGeneric<strin...
I have two related objects: ProgramSession and ProgramTask, with a one-to-many relationship. A ProgramSession has many ProgramTasks. So the objects looks like this:
public class ProgramSession
{
public virtual IList<ProgramTask> ProgramTasks
{
get { return _programTasks; }
set { _programTasks = value; }
}
}
...
Ok so I have a been making an addressbook application and have pretty much finished all the key features but I am looking to implement a sort feature in the program.
I want to sort an Arraylist which is of a type called Contact (contactArray) which is a separate class which contains four fields; name, home number, mobile number and addr...
when we can inherit from base class / interface, why can't we declare a List<>
using same classes / interface
interface A
{ }
class B : A
{ }
class C : B
{ }
class Test
{
static void Main(string[] args)
{
A a = new C(); // OK
List<A> listOfA = new List<C>(); // compile...
Maybe someone know how ListView pointer is stored/removed at ReadOnly Property ListView in ListViewItem? How is it implemented? I know ListViewItems are stored in ListViewItemCollection which has constructor New(owner as ListView) but I dont know how pointer to ListView is add/remove in ReadOnly Property in ListViewItem...
...
Hello
There is a set of methods like:
Foo(int, float, params objects[])
Goo(int, params objects[])
Too()
each taking different number of & type of parameters (so are return values).
I read an integer (an index) from a database. The integer corresponds to one of the above mehtod (1 for Foo, 2 for Goo and 3 for Too).
How do I st...
How can I update the values of one hashtable by another hashtable,
if second hashtable contains new keys then they must be added to 1st else should update the value of 1st hashtable.
...
Hello everyone,
I'm trying to bind to an item inside a collection but the index for that item needs to be "variable".
Take the following pseudo syntax for example:
<TextBlock Text="{Binding Fields[{Binding Pos}]}" />
Is something like this possible? If my property Pos is 1 it should bind to the first item out of the collection "Field...
I'm playing around with the DataGridView control offered by .NET.
Upon till now I seem to be unable to bind an (I)List to a DataColumn.
Is this possible and how should I go around doing this?
...
For a "log information for support" type of function I'd like to enumerate and dump active thread information.
I'm well aware of the fact that race conditions can make this information semi-inaccurate, but I'd like to try to get the best possible result, even if it isn't 100% accurate.
I looked at Process.Threads, but it returns Proces...
I am working on a project that involves me using a HashSet of a class I made, which I will name Test. I defined the stated HashSet like so:
HashSet<Test> t = new HashSet<Test>();
t.add(new Test("asdf", 1));
t.add(new Test("hello", 2));
t.add(new Test("hello", 3));
I tried using
t.contains(new Test("asdf", 1));
but it returns false....
I have a Map[Long, String] which I would like iterate over in descending order of the keys. The way I chose to do this was as follows:
var m: SortedMap[Long, String] = TreeMap.empty( (l: Long) => -l)
m ++= Map(2L -> "Hello", 1L -> "World", 3L -> "Chris")
println(m) //Map(3 -> Chris, 1 -> World, 2 -> Hello)
I'm really not sure I unders...
# array
C:\> (1,2,3).count
3
C:\> (1,2,3 | measure).count
3
# hashtable
C:\> @{1=1; 2=2; 3=3}.count
3
C:\> (@{1=1; 2=2; 3=3} | measure).count
1
# array returned from function
C:\> function UnrollMe { $args }
C:\> (UnrollMe a,b,c).count
3
C:\> (UnrollMe a,b,c | measure).count
1
C:\> (1,2,3).gettype() -eq (UnrollMe a,b,c).gettype()
True
...
I've created and populated a generic list of strings like this:
Dim MyList As New List(Of String)
MyList.Add("Beta")
MyList.Add("Echo")
MyList.Add("Charlie")
MyList.Add("Alpha")
MyList.Add("Delta")
Now I want to order it.
...
var a = new Collection<string> {"a", "b", "c"};
var b = new Collection<int> { 1, 2, 3 };
What is the most elegant way to iterate through both yielding a set of results "a1", "b2", "c3"?
...
Earlier I asked a question about merging a known number of dictionaries into 1 single DataTable: http://stackoverflow.com/questions/1831209/dictionaries-in-datatable
Darin provided me with a satisfactory solution to the problem at hand.
But my problemset has evolved. I can no long be certain of the amount of dictionaries I get supplied. ...
Hi.
Say I have a collection of @dogs, and I want to render part of the collection in one place and the rest in another. It's easy to spit them all out together:
render :partial => 'dogs/summary', :collection => @dogs, :as => :dog
But is it possible to manipulate (refine) your collection in-line, or is it better practice to make those...
It would be nice to use for (String item: list), but it will only iterate through one list, and you'd need an explicit iterator for the other list. Or, you could use an explicit iterator for both.
Here's an example of the problem, and a solution using an indexed for loop instead:
import java.util.*;
public class ListsToMap {
static ...
Is it possible to convert:
public IList Get()
{
return Session.CreateCriteria(typeof(T)).List();
}
to return IQueryable?
What is the difference between IList and IQueryable?
...