Hi I have Card class... In another class I create an arrayList of Card objects. How would I go about sorting the arrayList based on the value of the card? The ace is the lowest card value and the king is the highest.
A,2,3,4,5,6,7,8,9,T,J,Q,K
public class Card {
char rank, suit;
public Card(char rank, char suit){
...
Hi,
I just ran into a major issue for me with NHibernate. I have 2 objects, each with a collection of things. I need to move one thing from the collection from Object A to the collection of Object B. I get an error about a deleted object because, I believe, NHibernate attempts to delete the thing from the collection of Object A when it ...
Hello!
I want to make a class usable in SortedSet | SortedMap.
class MyClass implements Comparable<MyClass>{
// the only thing relevant to comparisons:
private final String name;
//...
}
The class' instances must be sorted by their name property.
However, I don't want equally named instances to be considered as equal.
So a So...
I feel that when I use NSArray, I might constraint myself some time in future. Are there any good reasons to prefer this "primitive" one instead of the "complex" one, which is mutable?
...
Hello.
I'm looking for an implementation of thread-safe blocking queue for .NET.
By "thread-safe blocking queue" I mean:
- thread-safe access to a queue where Dequeue method call blocks a thread untill other thread puts (Enqueue) some value.
By the moment I'v found this one:
http://www.eggheadcafe.com/articles/20060414.asp
(But it's for...
System.Collections.Specialized.NameObjectCollectionBase has two similar properties:
string[] AllKeys
NameObjectCollectionBase.KeyCollection Keys
Do they provide different sets of data? When would I want to use one over the other?
...
Hi all,
I am using VB.NET and I am trying to come up with some algorithm or some pseudo-code, or some VB.NET code that will let me do the following (hopefully I can explain this well):
I have 2 collection objects, Cob1 and Cob2. These collection objects store objects that implement an interface called ICob. ICob has 3 properties. A boo...
Using vb.net (vs2005), how do I populate a combo box with multiple property values from an object? Right now I'm iterating a collection of objects and adding the name property of each object to the combo box. I'd like to add multiple properties from the object to the list. For now, I'd be happy if they appeared comma separated in the lis...
Please suggest some elegant way to convert
arrays of arrays to collections of collections and vice versa in Java.
I suppose there's no convenience methods in the Java API, right?
public static <T> T[][] nestedCollectionsToNestedArrays(
Collection<? extends Collection<T>> source){
// ... ?
}
public static <T> Collection<Collecti...
In Java, the containsAll and retainAll in the AbstractCollection class explicitly state that cardinality is not respected, so in other words it does not matter how many instances of a value are on each side. Since all Java collections in the standard library extend AbstractCollection, it is assumed that all of them work the same.
Howev...
Hey, I just began to learn ruby/rails. At the moment, I try to do an example of a german book "Praxiswissen Ruby on Rails", which is pretty old and written for Ruby on Rails 1. Anyway, I tried to do the examples with Rails 2. Now I have had problem for over a week.
According to the book (Rails 1) I have to write in my controller:
pa...
Does anyone know where I can find an implimentation that wraps an STL map and makes it thread safe? When I say thread safe I mean that it offers only serial access to the map, one thread at a time. Optimally, this map should use only STL and or boost constructs.
...
Is there any practical difference between a Set and Collection in Java, besides the fact that a Collection can include the same element twice? They have the same methods.
(For example, does Set give me more options to use libraries which accept Sets but not Collections?)
edit: I can think of at least 5 different situations to judge thi...
In Java, I need to return an Iterator from my method. My data comes from another object which usually can give me an iterator so I can just return that, but in some circumstances the underlying data is null. For consistency, I want to return an "empty" iterator in that case so my callers don't have to test for null.
I wanted to write ...
This has been driving me crazy for a while:
DECLARE
TYPE AttrValueRec IS RECORD (
attr VARCHAR2(40),
val VARCHAR2(2000),
inst NUMBER(4)
);
FUNCTION create_attrval(attr AttrValueRec.attr%TYPE,
val AttrValueRec.val%TYPE,
...
Say I have a java.util.List list and I want to create a new List by adding an element e to the beginning of list (i.e., I want to cons e and list). For example, if list is
[1,2,3,4]
and e is 5, then cons(e,list) will be
[5,1,2,3,4]
It's OK for the elements of list and cons(e,list) to be shared, but list should not be modified.
Wha...
Is there a way in Apache Commons Collections to have a PredicatedList (or similar) which does not throw an IllegalArgumentException if the thing you are trying to add doesn't match the predicate? If it does not match, it would just ignore the request to add the item to the list.
So for example, if I do this:
List predicatedList = List...
I have a feeling that this is stupid question, but I'll ask anyway...
I have a collection of NSDictionary objects whose key/value pairs correspond to a custom class I've created, call it MyClass. Is there an easy or "best practice" method for me to basically do something like MyClass * instance = [ map NSDictionary properties to MyClass...
I have a utility class that takes a generic list as a parameter.
Code looks like:
Function DoStuff(collection as Object, elt as Object)
...
collection.Add(elt)
...
End Function
This is called with:
DoStuff( List(Of Foo), new Foo() )
DoStuff( List(Of Bar), new Bar() )
There are about a dozen different types.
Currently, pa...
In a SortedDictionary is it possible to change the value of an item ?
...