collections

AI Implementation for a Card Game

Hello; How can I implement a collection of three computer opponents in a client/server Java game? Thanks... ...

Elegant syntax for passing pairs of key -> value mappings to a function?

I'm working on an API which will read string values from a file and allow for type conversion. I also need it to provide a way of "mapping" given string values to a specific value of the desired type. That would look something like this: int val = myObject.getValue<int>("FieldName", { { "", 0 }, { "INF", int.MaxValue } }); The field...

what is the best way to structure this query

I have a IEnumerable collection of objects. The objects have a field LastedUpdated which is a DateTime field. I want to filter the collection, given a timestamp that I have, to return the record in the collection with that timestamp and the "next record" in time (based on this field) because I then want to have some code do a "diff" be...

singly and doubly linked list in java?

Hi Folks, Which collection interface is efficient to implement the singly and doubly linked list in java? code sample please? ...

Java Collections: Pass collection of children as collection of parents

Say I have an interface and some classes: public interface IPanel<ComponentType extends Component> { public void addComponents(Set<ComponentType> components); public ComponentType create(); } public class Button extends Component { } public class LocalizedButton extends Button { } public class ButtonsPanel implements IPanel<But...

Filter a product collection by two categories in Magento

Hi I'm trying to find products that are in two categories. I've found an example to get products that are in category1 OR category2. http://www.alphadigital.cl/blog/lang/en-us/magento-filter-by-multiple-categories.html I need products that are in category1 AND category2. The example in the blog is: class ModuleName_Catalog_Model_Resou...

DataAdapter: Is it possible to fill a Collection-Type instead of a DataTable/DataSet?

Hello, this is more a theoretical question i asked myself. I remembered that BinarySearch of an ordered List(Collection in general) is faster than finding Rows with Datatable.Rows.Find or DataTable.FindByPK with a primary key value. Hence i fill a Datatable from Database in a shared constructor and immediately after that a List(of Int3...

Comparing two collections

i have what seems like a common problem / pattern. two collections of the same object. The object has a number of properties and some nested objects within it. Car has a property called id which is the unique identifier. I want to find the LINQ way to do a diff, which includes: Items in one collection and not the other (visa versa)...

Store Collection of Data Fields and Retrieve Via Identifier

In C#, how can I store a collection of values so if I want to retrieve a particular value later, I can do something like: myCollection["Area1"].AreaCount = 50; or count = myCollection["Area1"].AreaCount; Generic list? I'd like to store more than one property to a "key". Is a class the answer? ...

Mapping collection of enum in NHibernate.

Hi all! I have a class with collection of enums: Class1.cs public enum Language { Serbian = 1, Croatian, Ukrainian, } public class Class1 { private IList<Language> m_languages = new List<Language>(); public virtual IList<Language> Languages { get { return m_languages; } set { m_languages = val...

Generic collections & dictionary classes with events

Implementing Document-View pattern I faced the problem: standard generic collections and dictionaries (List<T>, HashSet<T> for example) don't provide events for modification (OnBeforeAdd, OnAfterAdd, OnRemove, Freeze/Unfreeze methods... ) I suppose events were not implemented for optimization purposes but I have to use and listen for s...

return field diffs from 2 collections

i have two collections of the same objects (same size list of course). items can be matched by an IEqualityComparer (matching on a unique property of the object). I want to generate a new list out of these existing lists that just show the field differences of each of the "same" items from each collection. I was thinking of doing some...

How to cast a Dictionary into a CollectionDataContractAttribute decorated class

Hi, this is my first WCF service. I defined a response message that derives from a Dictionary like this: [CollectionDataContract(ItemName = "Product", KeyName = "ProductNumber", ValueName = "ProductName")] public class GetAvailableProductsResponse : Dictionary<string, string> { } When I try to run the following code in a service opera...

Fast String Collections in Java

I am using Java and I am looking for String Collections (Sets and Lists) that are optimized in space and are fast. My strings are of fixed size: either 3 or 5 chars long. Please suggest to me if there are any collection libraries available that can be best suited to me. I was thinking of some dictionary based collections. Thanks. ...

why doesn't .Except() and Intersect() work here using LINQ ?

i have the following code which doesnt seem to be working: Context: I have two lists of objects: * listOne has 100 records * listTwo has 70 records many of them have the same Id property (in both lists); var listOneOnlyItems = listOne.Except(listTwo, new ItemComparer ()); here is the comparer public class ItemComparer : IEqualit...

what would be the correct HQL query to get all rows who's collection contains another collection

hi, I'm looking to create a HQL query that does the following: public Collection getCollection(Collection sons) { //return collection of fathers who's have all of the sons from the param } i'm a bit mixed up as to when to use query is HQL syntax (join etc..) and when to use "Criterias" Thanks in advance ...

Query scalar collections in HQL

I have the following class: class User { String username; @CollectionOfElements private Set<String> roles = new HashSet<String>(); [many more things here] } And I want to write a HQL query that retrieves the username and the roles for all the users. Query query = session.createQuery("select distinct u.username, u.roles from User u");...

Problem with collections in GAE

Hi all. Learning GAE I`ve got some issue. I want to save contact list of my users in database. I use addUser() to add new user and it works. But when I refresh the page the list is empty (not null). In GAE "Datastore Viewer" the "list" field is null but in application it exists. @PersistenceCapable(identityType = IdentityType.APPLICATIO...

ICriteria, add restriction on collection contents

Hi all, Using NHibernate I'm trying to get obtain a list of B's where an IList property of B contains a specific instance of A. The following code should hopefully explain the situation more clearly: public void test() { A a1 = new A(); A a2 = new A(); B b1 = new B(); b1.As = new List<A> { a1 }; // ...database save...

Copying an SMO collection into an array in Powershell

I've written a Powershell script which will compare two databases and come up with a list of objects in one of the databases to remove. I put those items (as a customized object with a name and schema) into an array. In the next step of my script I iterate through the objects in the database and see if they match an object in my array. ...