Collections APIs provide developers with a set of classes and interfaces that makes it easier to handle collections of objects.
8
votes
3answers
127 views
Collection that can be modified in a foreach
Sometimes you want to add/remove items from a collection inside of a foreach loop. Since this isn't possible, a common pattern is to add the items to a separate ...
4
votes
3answers
65 views
Thread safe cache for write through and writeback
This cache is like a list where new elements are inserted in the middle, cache hits are put to head of the list and replaced elements are taken from the end. Would I just use a list the lookup would ...
1
vote
0answers
28 views
NonEmptySortedSet implementation
I'm looking for feedback specifically about what I might add to this to make it more usable or general, especially with regard to scala collection traits to implement.
...
4
votes
3answers
170 views
Generic sum method for a Collection<Number>
While answering this question, I wanted to use a generic sum of Collection function. Java doesn't have a native method, so I wrote one. There are a couple things ...
8
votes
2answers
204 views
Efficiently create and sort a Collection
The goal of my code is to sort data into two categories. It must use a local copy of the initial data from Collar (Top View).csv. My code creates a Collection of items called Collars using the initial ...
3
votes
2answers
246 views
Word Ladder Solution in Java using ArrayList
Word Ladder
Given a start word and a goal word, convert the start word to the goal word by changing one letter at a time. Each step must also be a valid word.
Is my code modular? I mean are ...
4
votes
1answer
53 views
C++11 lock free collection similar to std::forward_list - follow-up
Thread safe and lock free collections are very hard to write, so I'd appreciate any feedback, especially regarding bugs. The code below is a self contained cpp including some tests.
This question is ...
4
votes
2answers
108 views
Wiring CollectionView and grouping it without slowing it down
In my previous question, I got heaps of good advice BUT no solution for the problem apposed.
I applied the valuable learnings from the past on this.question and am also hitting it from a different ...
3
votes
3answers
155 views
Find intersection of two arrays without duplicates
A = [9, 1, 4, 2, 5] k unique integers
B = [3, 1, 8, 7, 6, 5] n unique integers
Intersection => [1, 5]
Find an algorithm that uses \$O(1)\$ space (the space used by the return variable is not ...
3
votes
3answers
110 views
Implementing a singly LinkedList and IList interface
I have implemented a LinkedList in C#. What would you change/make better? What naming conventions are misused? What would you add? Some of my ideas are to make it ...
2
votes
2answers
39 views
Remove list of files from another list of files by their name
In groovy I have a list of files A and also another list of files B. I want to remove all the files from A that have a filename that also occurs in the list of files B. I wrote the following code:
...
4
votes
1answer
70 views
C++11 lock free collection similar to std::forward_list [closed]
I'm new to explicit memory ordering, and any kind of thread safety is hard to implement right to begin with. Please let me know if you see any problems, or have suggestions for improvement. Written in ...
4
votes
2answers
88 views
Subsorting with multiple Comparators
I've seen a number of questions on Stack Overflow of the kind of "How do I sort on fields X AND Y?" The most common answers to those questions consists of "Write a custom Comparator."
But what if you ...
10
votes
3answers
335 views
Collection with both Set and List interface
Here's something I wrote a while ago. I needed a collection that was ordered, but also guaranteed duplicates did not occur. So I made a class with both Set and List interfaces. It seems to work ...
6
votes
3answers
138 views
Extension method to enumerate a hierarchical object
I have a domain object that I have no control over which itself contains a collection of this same type. This is a classical hierarichal representation like in a tree node hierarchy. I would like to ...
4
votes
1answer
71 views
Container adaptors
How to improve the functionality, exception safeness and other aspects of the following container adaptors?
Allows to write more generic code (not working for, say, ...
2
votes
1answer
130 views
ArrayList for Shop implementatin
Problem statement:
Design a system for the following scenario:
An item list contains item code, name, rate, and quantity for several items.
Whenever a new item is added in the list ...
7
votes
1answer
47 views
Joining collections… because it's fun
I'm working on a LinqEnumerable class (reviewable here), and I'm no Big-O expert and I'm pretty bad with algorithms, so I wonder what the complexity is for what ...
-1
votes
1answer
503 views
ArrayList implementation in C [closed]
Although I know I can use calloc then realloc to make a dynamic array in C, and that I also need a variable to keep track of the ...
2
votes
2answers
351 views
Having a class return a single database instance or list of all database instances
I'd like the following to happen:
...
2
votes
2answers
95 views
Performance enhancement for collection manipulation
I have below snippet of code which gets all the available menu items for a zone(top or left)and adds the widgets for which user has access to an ArrayList collection. For now the ...
7
votes
2answers
142 views
Array-like container for uints shorter than 8 bits (Rev 1)
This is a follow-up to Array-like container for uints shorter than 8 bits
In short: The PackedBitfieldArray should be a kind of container for packed (unsigned) ...
11
votes
1answer
145 views
Array-like container for uints shorter than 8 bits
Follow-up: Array-like container for uints shorter than 8 bits (Rev 1)
First of all: yes, I need this kind of array to generate data for a piece of hardware, and it must be stored and manipulated ...
-1
votes
2answers
96 views
LinkedVector : a vector of elements with links to other elements
I wanted to have a vector with usual values and with some sort of indexing : an element can have links to other elements (via indices). Something like the following, where ...
10
votes
1answer
178 views
Container with sorted by multiple keys
From this question:
Sorted vector (aka flat_set) for objects (pointers) with custom embedded key (functor used)
This is an example of a multi-index container. Note: this is not a container as ...
5
votes
3answers
124 views
Finding the closest value in a collection in a game-server plugin implementation
I have an array of a instances of an enum type. A random double variable is initialized with a value between 0.... to 1, and should be used to get the closest ...
5
votes
2answers
313 views
Concurrent Linked Hash Set
Basically I want to create a concurrent LinkedHashSet which returns proper size too.
I am mainly concerned about adding and removing iterations. Suggestions ...
5
votes
2answers
121 views
UniqueList Class in VBA
I often find myself abusing dictionary objects just for the exist method like this,
...
10
votes
3answers
404 views
Building a better Collection. Enumerable in VBA
VBA's 'Collection' is.... lacking, so, I've been working on a better Collection object that implements many of the features of C#'s Enumerable. This is very much inspired by this question and a follow ...
5
votes
2answers
147 views
Reducing the execution time of Online Community-Even Groups challenge
I have a coding problem for which I have attempted to solve with the below coding. However, my program is assessed as too slow in its execution and thus needs to be optimized to reduce the execution ...
10
votes
2answers
299 views
Sorting a collection
Related to, but not exactly a follow up of this question. After fixing some issues discovered in the last review, I added a little more functionality to the ...
8
votes
3answers
130 views
More imitation of Enumerable in VBA
I was inspired by Me How's question to see how far I could push an imitation of .Net's Enumerable Class.
The new functions can obviously handle Collections, but can also handle any collection-type ...
2
votes
3answers
66 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.
...
7
votes
2answers
193 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
101 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
104 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
138 views
8
votes
2answers
1k 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
95 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 ...
10
votes
2answers
271 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 this.
...
10
votes
3answers
2k 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
335 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
143 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 ...
7
votes
2answers
840 views
Deallocate all memory in a container of pointers
I want to erase all memory in a container. Currently I'm using this :
...
3
votes
0answers
119 views
Associative container that produces a unique, instance specific handle for each inserted object
It is not always possible to simplify program design by strictly managing the lifetimes of objects. If two objects have unpredictable lifetimes, but one of them needs to refer to the other, a simple ...
5
votes
4answers
396 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
102 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
124 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 ...
2
votes
3answers
116 views
Containers and lists
I want to create a container that has an AutoList object list. I wonder if my container is correct.
...
10
votes
1answer
365 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, ...