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)

0
votes
1answer
51 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: ...
6
votes
1answer
91 views

C++: multi-function memoizator and multi-type container

I'm trying to write a multiple functions memoizator, I talked about it here. The main problem is to create a container containing different and heterogenous functions. I found a working solution, ...
0
votes
0answers
20 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). ...
0
votes
1answer
59 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
59 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
53 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
331 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
37 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
43 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
82 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 ...
0
votes
0answers
30 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
85 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
87 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
208 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
155 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
111 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 ...
2
votes
1answer
136 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
78 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
55 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
103 views

Diffing two lists of business objects

dataListOne and dataListTwo will be full of BO objects (around 4000 - 5000). Lets say ...
1
vote
1answer
248 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
89 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
22 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 ...
4
votes
2answers
324 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
55 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
233 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
414 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
114 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
52 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
378 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) ...
4
votes
2answers
2k views

Loop through column cells and compare value with a Collection

I have a Collection of 166 elements: ...
0
votes
0answers
91 views

Custom ConcurrentHashMap for ints

I've implemented a concurrent hash map for int primitives. ...
3
votes
1answer
56 views

Removing an object which is wrapped in another object from a collection

I have Clips that can be added to or removed from any number of Lines. When I add the Clip, ...
10
votes
3answers
170 views

Writing a program to read a maximum of 99 elements in an iteration from a list

I want to read a list of elements and pass a maximum of 99 elements to a function for some logical operations. I have tried this with an array as an example and this code was successful in achieving ...
1
vote
1answer
51 views

Properly managing a collection from deserialized XML file throughout app's lifetime

I'm developing a WinForms app to manage some settings and profiles for multiple video games. The list of video games is specified by the user, and I'm trying to figure out how to properly maintain ...
4
votes
1answer
23 views

GroupBy field with and without white spaces

I have these invoices listed: ...
2
votes
3answers
111 views

Is one-sided equality more helpful or more confusing than quick failure?

My question is about the equals() method. Most people implement equals() to start like: ...
5
votes
2answers
3k views

Optimize method to iterate to over Map<String, List<Object>>

I have a Map<String, List<Object>> multiFieldMap and I need to iterate over its value set and add the value to ...
6
votes
1answer
125 views

Storing collections of objects of any type

I've put together a class whose goal is to store objects of arbitrary type, with each type having its own vector for contiguity. I'd like to gather advice on what I have so far before I carry on. Let ...
2
votes
2answers
371 views

Observable Collection “Deep”

In a project of mine I needed a class "Document" to be able to notify any change in its fields. This class keep a collection of class "AnotherClass". Using an ObservableCollection for this collection ...
2
votes
1answer
337 views

Fixed size double-ended queue

I require hundreds of equal, small sized buffers in my current project. The bulk of the computation in the program operates on data stored directly in those containers, so high performance is ...
3
votes
2answers
112 views

Simple medical collection/database about patients visits

I am writing a system for doctors who are regularly visited by patients. The doctor adds each patient's visit to collection/database. The class can save data to an .xml file and restore it. Can you ...
4
votes
2answers
573 views

C# Tree implementation

I’m working on a C# implementation of a tree class. The tree will be used wherever I need to store data in a tree format. (Application Menu, File Infos etc.). Therefore the tree should support a lot ...
5
votes
1answer
763 views

Hacker Rank: Extracting digits from a given number and check for divisibility

The problem in question is a coding challenge from Hackerrank: Problem Statement You are given an integer N. Find the digits in this number that exactly divide N (division that leaves 0 as ...
2
votes
1answer
79 views

The information system of the institution

I've made a small project from my institute. I've got 5 classes, in 4 of the classes (Teachers, Students, ...
4
votes
1answer
185 views

Union of intervals

I am trying to solve for the problem with a bunch of intervals: (1,2),(2,5),(4,7),(9,11) I find their union, which in the above given case would be: ...
0
votes
2answers
1k views

Array to Tuple in Swift

I am burdened with the requirement of interacting with a C based library, which has a bunch of constant sized arrays (e.g. char[17]). When trying to assign or read ...
8
votes
3answers
517 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 ...