collections

Magento get a list of products that are not related to any category

I was able to make an ordered list of categories with child products, now i need to add a list of products that are not related to any category ...

Create a designer-aware UserControl collection to be used runtime

I have a Panel I want to fill with some UserControl(s) at runtime. These controls are complex and may be interdependent, so I'd like them: to be editable with Visual Studio designer; to be in the same context (= defined in the same class); Both of the requirements are a must-have. Considering UserControl is itself an indexed collect...

Customizing XStream output

I have a class that resembles something like this: class foo { List<String> bar; ... } I add four Strings to the list bar: bar.add("1"); bar.add("2"); bar.add("3"); bar.add("4"); Using xstream, I've managed to get output that looks like this: <foo> <bar> <blah>1</blah> <blah>2</blah> <blah>3</blah> <b...

DDD along with collections

Hi, suppose I have a domain classes: public class Country { string name; IList<Region> regions; } public class Region { string name; IList<City> cities; } etc. And I want to model this in a GUI in form of a tree. public class Node<T> { T domainObject; ObservableCollection<Node<T>> childNodes; } public class Countr...

Intrusive list implementation for Java?

Is there any (well implemented) intrusive double linked list class(es) available for Java? Or should I do my own? Boost has it for C++: http://beta.boost.org/doc/libs/1_40_0/doc/html/boost/intrusive/list.html. Intrusive list is a container having (in this case) next and prev pointers within element, so typical list operations like repla...

What's the recommended way to return a boolean for a collection being non-empty in python ?

I came across the question Python: What is the best way to check if a list is empty? on SO. Now if I wanted to return a True (False) depending on whether a collection coll is non-empty (empty) from a function, what's the recommended way of doing this ? return not not coll ? ...

What's the best way to detach a Collection from a Map in Java ?

I obtain a HashSet from a HashMap and I don't want that my modifications on the HashSet reflect on the HashMap values. What's the best way of doing something like this : HashSet<Object> hashset = new HashSet((Collection<Object>) hashmap.values()); //Something like ... hashset.detach(); //Then i can modify the HashSet without modifying ...

Is there a way to avoid @SuppressWarnings in this code?

Is there a way to avoid using @SuppressWarnings below and to keep the same functionality without the warning 'Type safety: Unchecked cast from AbstractDO[] to E[]': public MyClass { ... private Map<Class<? extends AbstractDO>, AbstractDO[]> map; ... private void saveConcreteDOs(AbstractDO[] theEntities) { entityMap.p...

Binding to property of specific collection item in a ListBoxItemContainerStyle

I have a collection of Company objects contained in a CompaniesCollection which is inherited from Observable Collection. Via a CollectionViewSource, I am displaying these Companies in a list box. One of my requirements is that each company item must show the City and State of the first Address (of a collection of Addresses) attached to...

What's The Difference Between Java GC Log Lines? ("Total time for which..." vs "[GC")

Java Version: 1.6.0_20 I'm seeing the following in my logs, and I'm trying to figure out the difference beween the first line and the subsequent lines. As far as I know, they are both minor GC related, however there isn't a 1-to-1 between them as there usually is in other GC tutorials I've read. I know how to interpret the first line,...

Performance of built-in .NET collection sorters

There was a question asked about how to sort a List. There were several methods given from the basic List.Sort() to List.OrderBy(). The most laughable was a roll-your-own-SelectionSort. I promptly voted that down, but it made me think; wouldn't Linq's OrderBy(), applied to a list, do the same thing? myList.OrderBy(x=>x.Property).ToList()...

NotifyCollectionChangedAction: object instance on removal?

I am currently implementing the INotifyCollectionChanged interface for a collection with generally quite critical and short-lived items. All of those items implement IDispose, which can be called immediatly before the removal from the collection. I do not have any control about the destruction order, I will just have to take it as it com...

Find the smallest window of input array that contains all the elements of query array

Problem: Given an input array of integers of size n, and a query array of integers of size k, find the smallest window of input array that contains all the elements of query array and also in the same order. I have tried below approach. int[] inputArray = new int[] { 2, 5, 2, 8, 0, 1, 4, 7 }; int[] queryArray = new int...

Where are all the esoteric collection template libraries?

Suppose I want a collection type that isn't really supported by anything in the STL or by BOOST, like a spacial index or a fibonacci tree (if i think that might be useful on my really big dataset). Is there a good place to find these kinds of less common tools? ...

Inheriting List<T> to implement collections a bad idea?

Hi All, I once read an article by Imaar Spaanjars on how to build 3 tier applications. (http://imar.spaanjaars.com/416/building-layered-web-applications-with-microsoft-aspnet-20-part-1) which has formed the basis of my coding for a while now. Thus I implement collections as he has done, by inheriting a List<T>. So if I have a class na...

is it possible to design a better collections library than stl for c++?

the title says it all... now answer! ...

Java oneliner for list cleanup

Is there a construct in java that does something like this(here implemented in python): [] = [item for item in oldList if item.getInt() > 5] Today I'm using something like: ItemType newList = new ArrayList(); for( ItemType item : oldList ) { if( item.getInt > 5) { newList.add(item); } } And to me the first way looks a ...

Magento products gallery

i don't know if my title is ok, but what i'm trying to do is something like a gallery or at least my client call it this way...lol..... i'm trying to do something like the seach result page but without a search criteria, without a filter, just click in a link and see a list of products, with the same funcionality, change the view mode(Gr...

Java collections covariance problem.

Lets say we have a program which contains such classes: public interface AbstractItem { } public SharpItem implements AbstractItem { } public BluntItem implements AbstractItem { } public interface AbstractToolbox { //well the problem starts here... public List<AbstractItem> getItems(); } public ExpensiveToolbox implements Abstr...

Interfaces in collections framework

My question is Interface Set has method add(E e) and it extends interface Collection. Interface Collection also has method add(E e) So why do we need the same method in interface Set , since it already extends interface Collection. What is the purpose ? I am stuck with that ...