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

learn more… | top users | synonyms (1)

1
vote
0answers
7 views

constant sized circular (ring) buffer

I've implemented constant sized circular buffer. It provides push and pop operations, along with modern emplace. It is also optimized for destruction of trivially destructible types. I didn't include ...
2
votes
1answer
22 views

Hotkey detection for UI elements

I have several UI elements that can be opened using hotkeys for example the settings menu's key is Escape. The problem is that I have the Keycode stored in ...
3
votes
0answers
32 views

Deque class using typing module

I wanted to make a class for type hinting that the result of a function is a homogenous deque. ...
3
votes
3answers
97 views

Custom struct design: Range

I had a need for some inventory management in a recent project. I decided to create a custom struct for managing the concept of a number range. It allows for easy navigation of a collection. It ...
4
votes
2answers
96 views

Find maximum value of Point represented by an Array of values for each coordinate

Suppose there is an array A = {3,2,5}, then points for this array correspond to indexes (i,j) where ...
3
votes
1answer
33 views

Unit tests for custom Map wrapper

A while ago I asked for a code review of my automatically keyed map and I have recently had the time to get around to writing some unit tests for it using JUnit4. The test ensures that all of the "...
-1
votes
1answer
52 views

Searching into a contact list

I am performing search in a contact list using linear search with complexity \$O(n)\$. Please suggest me how to improve search strategy in my code. ...
3
votes
1answer
48 views

class Taboo<T> — sort passed in List<T> according to 'rules'

I know as a matter of fact that there are many areas upon which my code could be improved. I was wondering if anyone can provide me with suggestions on how Taboo ...
5
votes
2answers
65 views

Scrabble Tile Counter

Introduction Inspired by this r/dailyprogrammer problem, I've written a Scrabble tile counter. Given a Collection of Scrabble tiles known to be in play, it can ...
4
votes
2answers
138 views

Find items that appear the same number of times in two collections

Here is a Java collection puzzle I found online. I was wondering if anyone can provide me with suggestions on how Appearance and tests can be improved. Suggestions ...
2
votes
1answer
71 views

Simple Contains() Function

I wrote simple generic function to check if any STL container has an element. It seems work fine. I have tested it with VC++, GCC and Clang compilers. It works perfectly. How can I improve it further....
2
votes
2answers
70 views

Multidimensional dynamic array class using a continuous block of memory

The following code is designed to be a multidimensional array that works off of a continuous block of memory. It is designed to be able to be resized at runtime, but only when a resize is explicitly ...
3
votes
3answers
103 views

C++ Dynamic array based stack

This is my first post so if I am doing something wrong in the post please let me know. I have implemented a dynamic array based stack. Can someone point out any pitfalls or things that can be done ...
1
vote
0answers
39 views

.NET List Serializer design

A few weeks back I wrote a class to help serialize/deserialize objects file. The file format requested was json, then compressed. After some coding/testing I settled on this design: ...
2
votes
1answer
83 views

Auto-resizing array, that accepts negative indexes

I've been coding a helper container template to contain tiles in 2D games. What I figured out I would like when writing code for my games is forgetting all resize stuff, allowing negative indexes (for ...
3
votes
1answer
33 views

Buffered read from a large list

There is a large list of email addresses and there is a limitation of max 100 email addresses to process once. This is the code I have written. ...
3
votes
2answers
38 views

Automatically keyed map

I have written a class that is designed to be an automatically keyed Map in Java. Here is my implementation: ...
2
votes
1answer
112 views

Searching two different elements in a same list

I have a list of conversion histories, where information about user channels is stored. For example user may have app for iOS and Android installed. Each time user logs in, I store a conversion ...
0
votes
1answer
54 views

HashMap or other collection?

I need to parse a space- delimited text file. I want to read the file and do operations for each cell. Here is how I am parsing the file: ...
7
votes
0answers
118 views

Multi-function memoizator and multi-type container

I'm trying to write a multiple functions memoizator, which I've talked about here. The main problem is creating a container containing different and heterogenous functions. I found a working solution,...
1
vote
1answer
30 views

Find items in collection one that are the greatest value less than an item in collection two

This is hard to explain. I wanted to get all of the items in collection one (ints in the example below) that are the highest values that are lower than any of the items in collection two (otherInts). ...
1
vote
1answer
81 views

Using T type parameter to clone a collection

I want to clone a collection with the following method and I want to know if it can be optimized: ...
1
vote
1answer
62 views

Returning a collection of unique elements: List<T> using Contains() or HashSet<T>

I'm writing a binary PowerShell module and have recently started to add wildcard support to some cmdlets. I'm not sure if I'm using an efficient way of creating the final collection of objects to ...
0
votes
1answer
58 views

A Java subclass of ArrayList that supports rotation in constant time - follow-up

(See the previous (and initial) iteration.) Compared to the previous iteration, I have added more methods that maintain the invariant required for constant time rotations, such as bulk add/remove, ...
7
votes
3answers
343 views

A Java subclass of ArrayList that supports rotation in constant time

(See the next iteration.) I have subclassed java.util.ArrayList in order to be able to "rotate" it in constant time simply by moving a finger index. See what I ...
2
votes
1answer
46 views

Comparing two shuffling methods

I'm trying to randomly shuffle an collection of integers within a List and I have came up with two shuffling method that does the job. However, I'm not sure which ...
1
vote
0answers
48 views

Update method using timer in WinForms Poker app

I have a WinForms Poker app that needs to update some stuff and im doing this by using a timer: ...
2
votes
1answer
90 views

Poker app in C#

I am developing a poker application using C#. It is almost done, and I'm looking for improvements. One of the things I wonder is whether I should change my method that checks if the player has a flush....
0
votes
0answers
34 views

Splitting two ObservableCollections lightning fast

I'm working on wiring up a bindable Map for Xamarin Forms, and I need a fast way of dividing up the ObservableCollections (collection of map markers) as quickly as possible. Collections are a weak ...
-1
votes
2answers
89 views

PHP Dependecy Injection Container

A few weeks ago, I asked for another DIC review, but didn't get any response (but only for one about my error handling). So I tried to rework my DIC without any outside insight on it, and the first ...
4
votes
1answer
100 views

Skip list in Python

I've made an attempt at writing a skip list in Python. I'm using NumPy to generate geometric random variables, but since that's a bit of a heavy dependency to drag around I could easily implement that ...
5
votes
2answers
330 views

Custom sorting of dates

I have implemented a class which implements a list of my custom DateObj. I have sorted the list in a peculiar manner based on the current month. I achieved my ...
3
votes
0answers
276 views

GSL-like array_view implementation

I've seen a couple GSL-like string_view-ish implementations on CR recently, but don't recall seeing anything like array_view yet ...
0
votes
2answers
78 views

Combining several collections into one

Is there a way to rewrite this code to make it more laconic? I'm using Java 6. ...
4
votes
3answers
124 views

Loops to merge documents and renumber pages

I have a for loop implementation for merging documents and page re-numbering. But since I am modifying the collection while iterating, I suspect that the code might ...
3
votes
2answers
348 views

Custom Implementation of ObservableDictionary

I recently found myself in need of an IDictionary<TKey,TValue> implementation that was observable from a WPF UI. Since the .Net framework does not provide ...
4
votes
3answers
86 views

File Parsing in Java Using Collection

I have the following requirements: /* Collection Write a program that counts the number of unique words in a large text file. a] Store the words in a collection and report the number of ...
1
vote
1answer
56 views

IReadOnlyCollection with notifications

It is not related to GUI. I have a class with: Private List, which is edited inside the class. Open IReadOnlyCollection ...
1
vote
3answers
107 views

Diffing two lists of business objects

dataListOne and dataListTwo will be full of BO objects (around 4000 - 5000). Lets say ...
1
vote
1answer
409 views

Ordered dictionary in swift 2

Loosely basing myself on this blog post, I implemented an ordered dictionary. In essence, it's a wrapper struct for a list of tuples with some initialisers and some functions (map, filter, toArray, ......
10
votes
1answer
99 views

ConcurrentDecayingHashMap<K,V>, a concurrent decaying HashMap

I wrote a wrapper for Java's ConcurrentHashMap that enables you to add a decay time to inserted values, meaning they will be automatically removed after the given ...
1
vote
0answers
25 views

Custom expression that filters elements based on jQuery internal data

With jQuery, I'd like to be able to easily select the following types of elements: Elements that have a specific value set for a specific data attribute in the raw HTML Elements that have had a ...
5
votes
2answers
545 views

Mean, Median and Mode of a QVector

I would like some help condensing this code down to size. I am trying to utilize Qt's container classes as efficiently as possible. I do not believe this code reflects my objective. ...
1
vote
0answers
56 views

Better way to deep copy than this? How can I make it generic by `Collection` type?

Could I make this method for deep copy generic to the Collection type? That method is so simple and I can't imagine ever needing to change it, so maybe I should ...
6
votes
1answer
279 views

Finding anagrams

I recently had a potential employer send me a programming test to read through a file and write to another file all the words that were anagrams (two or more words containing the same letter). The ...
5
votes
2answers
462 views

C++ equivalent of Python's deque with maxlen - sliding window

In Python it is really easy to get sliding window functionality using a deque with maxlen: ...
4
votes
2answers
162 views

Find if the prefix of the string exists in the values of the hash table

I have a hash map which maps to some strings which serve as prefixes and are of small length (max length is 6): ...
7
votes
3answers
58 views

Pulling Docker Machine IP

I am working with MongoDB through Docker, and I have a terrible bash command to pull the Docker Machine IP so I can sanely connect locally. ...
6
votes
1answer
542 views

Efficient top k words using MultiMap (Google Guava ext lib JAR)

Basic algorithm: Open document/huge text file Use Map and List to separate the words. \$O(K)\$ time complexity (TC) ...