Collections API's provide developers with a set of classes and interfaces that makes it easier to handle collections of objects.

learn more… | top users | synonyms

0
votes
0answers
38 views

Java GS Collections ImmutableList implementation [closed]

The following code is taken from GS Collections implementation of immutable Lists. Is it good practice to perform the above chain of construction for small lists of size <=10 ? ...
2
votes
3answers
39 views

Code to evaluate a dotted quad IP address has clumsy use of inject/fold - can I match the pattern in Ruby?

I wrote this to consume valid IPv4 addresses in dotted-quad decimal form. ...
6
votes
0answers
71 views

Interface-based polymorphic collection

Here is a small C++11 utility collection to store any object that satisfies a given interface. Only the basic concepts are provided, I did not try to create a full collection: ...
8
votes
2answers
92 views

Splitting two lists into OnlyA, Both, and OnlyB

This is a part of my Minesweeper analyzer code that didn't fit into the last question. This code uses FieldGroup which ...
3
votes
1answer
34 views

Construct KD-Tree in Java

I want to construct KD-Tree from unsorted List of points in the plane (i.e. 2-KD-Tree). To do so I used the method from Wikipedia: http://en.wikipedia.org/wiki/Kd-tree#Construction This is my code: ...
1
vote
1answer
50 views

Static map initialization [closed]

I have the following "working" static map: ...
8
votes
2answers
338 views

Efficient way of sorting a List based on multiple properties using Google Guava

I'm using Google Guava 17.0 library. I have a class named AroundBust containing only two properties id of type ...
4
votes
1answer
80 views

Finding the longest word from a list of words

I have a list of words (with repetitions), and I intend to find out the longest words amongst them, along with their length. My question is to know if my implementation is too verbose, is using too ...
2
votes
0answers
52 views

Twitter Streaming Client - Round#2

This is round #2. The initial code review is: Twitter Streaming API Client: Identifying the top trending hashtags for a specific term. For a list of changes since the last review please see: ...
10
votes
3answers
563 views

Sorting numbers using Java Collections.sort()

Input is a file containing numbers in this format: 1.2 3 5.1 2 7 4 6 5 2 9.22 1 0.0 4 3 I am doing the sorting in the simplest way, using ...
2
votes
1answer
48 views

Generic util method to convert in single map from list of array of Object generally result of JPQL/ hibernate

I have designed a generic method to convert list of array of Objects to result into single map. This is working fine, but I want to check weather a key object is valid key (whether it is overriding ...
0
votes
1answer
56 views

Filter a collection

In my project, there are some methods which filter some items from a collection. I was told to use the C++ STL whenever I can. But when I use std::copy_if, I feel ...
5
votes
4answers
335 views

Iterate over two collections of equal length

What's the best way to iterate over two collections of equal length? Currently I'm using this: ...
4
votes
2answers
76 views

Addition plus division taking up all my CPU - Kinect depth denoising

I have a method in my class that eats up something like 80% of my processor time while its running. In-fact one line within the method is responsible for the majority of this. The idea behind this ...
6
votes
3answers
120 views

Detecting available List operations

I'm writing some code which needs to take a generic java.util.List from another source and adapt to the available functions; eg. does it support ...
9
votes
1answer
243 views

Is my C++11 generic container a good design?

After refactors and refactors and the discovery of very common patterns on many of the classes of the software I wrote, I decided that it would be fine to have something like an arbitrary-keyed map, ...
4
votes
1answer
76 views

Does the class have unnecessary and violating Single responsibility principle method?

I encountered with the following code in the work. The MyItemCoordinator should receive MyItem objects, process them, add them ...
7
votes
3answers
512 views

Implementation of stack using pointers

Please review my code and let me know how I can possibly improve it. ...
18
votes
4answers
2k views

Just a lowly counter that turned out to be surprisingly complicated

While writing this review, I saw a need for a Counter object similar to Python's. It seemed like it would be easy to write such a class, but it turned out to be ...
6
votes
2answers
104 views

Clean, efficient and extensible code for querying collections

I recently wrote code that would query a collection of objects and rank them according to a given criteria and then filter based on an object property. I attach the code below. I would like to know if ...
10
votes
3answers
274 views

Unrolled linked list

Does anyone have any feedback on my unrolled linked list class? I did it just for fun. I am interested in the performance tradeoffs of linked lists, standard lists and unrolled linked lists. This ...
5
votes
1answer
65 views

One-line initialisation for a constant list with all entries except one from another list

I'm looking to simplify the initialisation of the second constant, preferably to just one line. Any ideas? Anything from Guava or JDK (up to 1.6) is ok to use. ...
3
votes
3answers
88 views

Forcing type-safe IDs for use with Collections and Maps

Introduction I have a hierarchically nested tree class (like SampleFolder, s.b.) that I want to serialize. The problem arises with the collection of sub items ...
5
votes
3answers
338 views

Inserting interval into a collection

The task is fairly simple. I want to create a collection of intervals and implement an Add method which would insert new intervals to the collection and merge ...
3
votes
1answer
39 views

Hierarchy with `list<self>` type

I want to establish a hierarchy, where at each level of the hierarchy, each type can contain a list<its own type>. So ...
5
votes
1answer
94 views

Is this a good way to cascade a property?

I'm trying to write a simple game. I have an Entity object, that has a list of Sprite objects. Each Sprite has a position property where it is drawn on the screen. Sometimes, an entity can contain a ...
2
votes
2answers
129 views

Assigning list index values to String

I am just trying to convert each list of values to String by index one by one. My Code is running fine. But I am thinking that I can write better code than this. I Need your good coding possibilities ...
11
votes
2answers
891 views

List<T> implementation for VB6/VBA

Recently I decided VB6's Collection wasn't enough for my needs, so I decided to implement something like C#'s List<T>. ...
3
votes
2answers
296 views

Kings Drinking Game

This Review Request evolves into this Review Request now with a custom UI and other changes. I wrote a program to simulate the drinking card game Kings. This is my third Java Project. I didn't quite ...
1
vote
1answer
363 views

How to observe nested objects

By having two model classes Conversation and Message, what are the best practices to handle the next situation: A conversation ...
1
vote
2answers
175 views

A custom Java collection which doesn't support nulls

I am making a GWT application and have to prevent client code from using null values in collections. I found an answer but GWT doesn't support Queue and its ...
1
vote
2answers
73 views

Write a class with some properties and indexed

Is there a better way to write it? I need the best way to write it. It is this principle? Please show me a better way it breaks SRP? ...
1
vote
4answers
566 views

Extension Methods for Trimming List

I'm currently working on a project that I had to create basically a running queue of items. My thought was to do this by a list, but surprisingly there weren't any methods to remove the first sequence ...
1
vote
1answer
875 views

Class for Map of Maps

After finding myself sometimes needing a map of maps, and as I couldn't find one in existing libs (like Guava), I wrote my own implementation. Do you think this version is okay? Specifically: Is it ...
2
votes
5answers
1k views

Divide group of numbers into two groups of which the sums are equal

I have a piece of code that divides a group of numbers into two groups of numbers of which the sums are equal. I created this because of a Stack Overflow question: For example: {10,15,20,5} will ...
0
votes
1answer
306 views

Java concurrent Map of List

I need concurrent HashMap of List as value with following behavior: count of read/write ops approximately equals support add/remove values in lists thread safe iterations over lists After some ...
-1
votes
2answers
310 views

What is a good name for bidirectional dictionary structure? [closed]

I'm writing a generic bidirectional dictionary which will be a part of a (somewhat) public API. This is how the dictionary works: It will hold key-key pairs where ...
1
vote
1answer
98 views

Does refactoring a while loop increase CPU usage

While upgrading our code base to take advantage of new features in .Net 4.5, I'm trying to refactor our take of the classic Producer/Consumer algorithm, but I'm concerned my refactoring is going to ...
4
votes
3answers
266 views

Cached empty collections

I often find myself in need to create empty collections. One of those days several years ago, I wrote something like the following to address that: ...
3
votes
2answers
106 views
10
votes
2answers
6k views

Add/Remove items thread-safely in List<T>

Recently I had to lock collections (of type List<T>) when items were added or removed. Because several collections were used in given code instead of creating ...
7
votes
5answers
358 views

A simple unrolled linked list implementation

I tried to implement an unrolled linked list in C#. I only needed to add things and clear the whole list so I didn't implement IList<T> (I tried but it was ...
8
votes
1answer
2k views

Thread-safe LRU Dictionary in C#

Can't seem to find one, so trying to build a very simple but fast implementation. Thought I would post on SO for review/feedback, and so that others can just copy/paste for their own use. I'm using a ...
3
votes
1answer
676 views

Generating all subsets of a given set

I am learning Java Collections Framework. Can someone look at this code for generating all subsets of a given set and tell me any issues with it. ...
3
votes
3answers
1k views

ReadOnlyCollection - my alternative to .NET one

I wanted something more flexible than System.Collections.ObjectModel.ReadOnlyCollection. The goal was: consuming classes should only see what I want to show them, not whole underlying collection. For ...
1
vote
1answer
544 views

I am trying to re-write the ATM problem using collections. This is for personal learning. Can you please provide your comments

The problem statement is Write a CashWithDrawal function from an ATM which based on user specified amount dispenses bank notes. Ensure that the following is taken care of Minimum number of bank notes ...
4
votes
2answers
364 views

Iterating thousands of times over large collections: advices

This is a pet project :) I have hundreds of playlist files .m3u whose many entries have a wrong path. I'd like to fix them programmatically. Suppose one of my .m3U contains the following entry: ...
2
votes
1answer
2k views

Get int array from database Cursor

I find this code quite ugly, but in fact, I can't find a finer way of achieving the goal. ...
1
vote
1answer
657 views

PHP Class to Represent a Type Collection

Here is my attempt at a PHP class to be used as a base class for typed collections. My goals with this are: to be able to access collection members with foreach to be able to access collection ...
2
votes
1answer
171 views

Defining transpose on a collection of irregular collections

I was asked to submit my request for code review on http://stackoverflow.com/questions/10672046/defining-transpose-on-a-collection-of-irregular-collections here. This is a follow-up to the post I ...