Why are the methods contains() and indexOf() in the Java collections framework defined using o.equals(e) and not e.equals(o) (where o is the argument of the methods and e is the element in the collection)?
Anyone know the reasons of that?
...
I have a Seq containing objects of a class that looks like this:
class A (val key: Int, ...)
Now I want to convert this Seq to a Map, using the key value of each object as the key, and the object itself as the value. So:
val seq: Seq[A] = ...
val map: Map[Int, A] = ... // How to convert seq to map?
How can I does this efficiently a...
I would like to call 'contains' on my Iterables :-)
...
I'm binding a GridView to a collection of objects that look like this:
public class Transaction
{
public string PersonName { get; set; }
public DateTime TransactionDate { get; set; }
public MoneyCollection TransactedMoney { get; set;}
}
MoneyCollection simply inherits from ObservableCollection<T>, and is a collection of MyMon...
I would like to know how people are going about validating collections in WPF. Lets say for example that I have an observable collection of ViewModels that I am binding to the items source of a grid, and the user can add new rows to the grid and needs to fill them.
First of all I need to validate on each row to ensure that required fiel...
So I have a List collection that I fetch via a API call (which I don't have any control over).
The list is ordered.
public class Article
{
int articleID;
string Url
}
So I have a Url value, using that I want to figure out the next and previous Url's if any.
What's the most elegant way of doing this?
...
I there any new use of the new .net 4 ISet collections with NHibernate?
...
I have three partials that I'd like to consolidate into one. They share the same collection, but each gets passed its own :local variable. Those variables are used for specific Models, so as a result, I have three different calls to the partial and three different partials.
Here's the repetitive code:
<% for email in campaign.email...
How can I indicate that a method will return a collection of objects in UML? Is there a better way to explain the relationship than to have a collection class as a return type?
...
What will prompt one to use this method?
Update : I see the point now. I like the reason of Uri "Shuffling is not a trivial algorithm". That is quite true.
...
Hello All,
I have a following ArrayList,
[Title,Data1,Data2,Data3]
[A,2,3,4]
[B,3,5,7]
And I would like to convert this one like this,
[Title,A,B]
[Data1,2,3]
[Data2,3,5]
[Data3,4,7]
I'm bit confused with the approach. Any hint would be much appreciated.
Thanks.
...
Could anyone help me telling me how to use scala's ObservableSet trait?
Thank you very much in advance
...
I am building some equations in F#, and when working on my polynomial class I found some odd behavior using List.mapi
Basically, each polynomial has an array, so 3*x^2 + 5*x + 6 would be [|6, 5, 3|] in the array, so, when adding polynomials, if one array is longer than the other, then I just need to append the extra elements to the resu...
Problem: I am trying to update a List. If a certain item's ID already exists in the List, I want to add onto that item's quantity. If not, then I want to add another item to the list.
cart = (List<OrderItem>)Session["cart"];
for(int counter = cart.Count-1; counter >= 0; counter--)
{
i...
When I evaluate a for in Scala, I get an immutable IndexedSeq (a collection with array-like performance characteristics, such as efficient random access):
scala> val s = for (i <- 0 to 9) yield math.random + i
s: scala.collection.immutable.IndexedSeq[Double] = Vector(0.6127056766832756, 1.7137598183155291, ...
Does a for with a yield ...
Hi,
I have a data source ('SampleAppearanceDefinitions'), which holds a single collection ('Definitions'). Each item in the collection has several properties, including Color, which is what I'm interested in here.
I want, in XAML, to display the Color of a particular item in the collection as text. I can do this just fine using this co...
I used FxCop to analyze some code I had written. I had exposed a collection via a setter. I understand why this is not good. Changing the backing store when I don't expect it is a very bad idea. Here is my problem though. I retrieve a list of business objects from a Data Access Object. I then need to add that collection to another busine...
I want to have class that can be instantiated with list, array, seq, set, stack, queue etc.
In my opinion
class A
class B(elems:A*)
should handle such stuff.
This is my solution:
class A
class B(elems:Iterable[A]){
def this(elem:A) = this(Seq(elem))
}
Can you suggest any improvements?
...
Hello. In looking through samples I have seen a number of examples where it is possible to present data within a wpf applicaiton by binding to collections. However I was wondering is it possible to write to a collection from an applicaiton. Say for example i have 2 or more fields such as names and I wanted to have hte ability to add up t...
If I have a hash map and iterate over the objects repeatedly, is it correct that I'm not guaranteed the same order for every call? For example, could the following print two lines that differ from each other:
Map<String,Integer> map = new HashMap<String,Integer>()
{{ put("a", 1); put("b", 2); put("c", 3); }};
System.out.println(map);
...