Questions tagged [collections]

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

Filter by
Sorted by
Tagged with
2 votes
1 answer
37 views

A collection based on a bitset to store a set of unique integers from a given range (rev. 3)

All right, let's do this one last time. This is continuation of this review. I applied most of the proposed changes, making interface of my container very close to that of ...
Piotr Siupa's user avatar
4 votes
1 answer
69 views

A collection based on a bitset to store a set of unique integers from a given range (rev. 2)

This is a continuation of this review. I applied most of the proposed changes. These changes were focused mostly on decoupling the class from the rest of the program and making its interface more like ...
Piotr Siupa's user avatar
2 votes
3 answers
85 views

A dynamic array with an iterator compatible with std::sort

I wrote a Vector (dynamic array) class with an iterator usable with std::sort() . It seems to pass my tests. I wondering about the issues one can spot on this ...
KcFnMi's user avatar
  • 119
1 vote
1 answer
78 views

Collection that uses a bitset to store a huge set of unique integers from a given range (rev. 1)

Some (skippable) context: I'm writing program that minimizes an arbitrary logical function. Such function takes an unsigned integer as an argument and returns either ...
Piotr Siupa's user avatar
1 vote
1 answer
41 views

SynchronizedObservableCollection: a thread-safe ObservableCollection

After reading many people talk about the need for a SynchronizedObservableCollection and their implementations I decided to roll my own. I wanted to add a ...
HackSlash's user avatar
  • 382
3 votes
1 answer
110 views

std::list reimplementation for practice

I used cppreference list to implement this simplified std::list. The CXX_STANDARD is 11. My questions are the usual: Is the ...
Abner's user avatar
  • 39
0 votes
0 answers
74 views

Grouping and summing by condition from three mongodb collections

I have three mongodb collections. I would like to group the collections by date, month and year, then sum by condition in order to display totals from the three collections in one table. However, i ...
user20183888's user avatar
3 votes
2 answers
317 views

C macro based dynamic array library

This library is a fork of eteran/c-vector. It is macro based, so that it is generic, without void pointers and additional functions. This of course means that it has the downsides of macros in C. The ...
DuckHunterZx's user avatar
3 votes
2 answers
128 views

Sort a dict by keys, assuming keys are orderable

I found a suspicious code snipped in an existing project in which I am involved as a developer. The code sorts a dict by its keys, so that if iterated over the dict,...
Looser User's user avatar
3 votes
1 answer
385 views

Yet another sparse set implementation

I got inspired by this blog post and implemented a fixed-size sparse set, removing the need for vectors, because the sparse set's size equals at least ...
Tab's user avatar
  • 33
6 votes
2 answers
1k views

A not so simple C++20 circular queue

This container reduces the number of memory allocations on queue-type operations (push + pop) compared to std::deque. Basic performance tests indicates a performance similar to std::deque where main ...
Gerard Torrent's user avatar
2 votes
1 answer
198 views

Simple C++ circular queue

I wrote a simple C++20 circular queue. https://github.com/torrentg/cqueue Here is cqueue.hpp ...
Gerard Torrent's user avatar
0 votes
1 answer
47 views

Iterating over JSON more effectively

Problem: I need to get data from JSON file containing information about "contributors". Each contributor has an atrribute jobs, which is a list of string-...
JoshJohnson's user avatar
1 vote
1 answer
107 views

Class that wraps a collection and tracks if its elements were visited

The VisitedCollection is a collection wrapper for setting and tracking if elements were visited (removed in terms of the wrapper) I have concerns regarding: should ...
triclosan's user avatar
  • 254
2 votes
3 answers
164 views

How to efficiently build an object from list or array of strings

I am working with an API that delivers some data in a QStringList or basically a list of strings. The data contains keys and values but it is not a ...
DEKKER's user avatar
  • 121
1 vote
2 answers
511 views

Implemented Sorting of Map by Value and then by Key in java

So I had this requirement to get the frequency of names appearing in a list and then print the one appearing the most number of times. If there is a clash, print the one which comes first in the ...
Janardhan Maithil's user avatar
0 votes
1 answer
716 views

std::list implementation learning exercise

I want to improve my algorithms and data structures in C++ understanding and also learn how the standard library containers are implemented. I implemented a std::vector in a previous review and this ...
arcomber's user avatar
  • 2,449
0 votes
1 answer
2k views

Faster way to find items from one list in another one [closed]

I would like to check if a string appears in a list of strings. For that, I have chosen the List<string> type, as follows: ...
Dominique's user avatar
  • 301
5 votes
1 answer
286 views

C smart string implementation using preprocessor

I have wrote a smart string container implementation for use in my application, but as I'am not such professional C programmer I have doubts about is I'am did it right and is there ways how to improve ...
Alex's user avatar
  • 53
5 votes
2 answers
197 views

std::vector implementation learning exercise

I want to improve my algorithms and data structures in C++ understanding and also learn how the standard library containers are implemented. This resizing_array is based on the std::vector. My ...
arcomber's user avatar
  • 2,449
1 vote
0 answers
999 views

Spring Boot Integration Test with SQS and Elastic Search

I have the following integration test that starts with sending message to sqs queue and ends with checking elastic search if the associated object added to db. The part of application I want to test ...
Davis's user avatar
  • 53
-1 votes
1 answer
75 views

Most efficient way to track a collection of targets in range of a source object [closed]

In my game there are space ships and each of these space ships tracks which other ships are in range of it. I need to perform certain logic when a target ship comes in range of another ship, and ...
wilderness26's user avatar
0 votes
1 answer
173 views

Action on each element of an inline list

I'm trying to learn the "functional" part of C#/.Net for work, and I'm not sure if this is a good way to write this statement. I was also trying to reduce duplicated code while not ...
Classiest's user avatar
3 votes
1 answer
86 views

C Typed Vector that implements type-safety, encapsulation and lazy initialization

C Typed Vector I wasn't happy with the various dynamic array / vector implementations in C, so I made my own. In general, I'm not the biggest fan of C-preprocessor madness, but alas for this ...
Julius's user avatar
  • 171
3 votes
0 answers
223 views

Implementation of Dynamic Array with allocators and C++20

To train my skills in C++, I decided to implement the well-known "Dynamic array" data structure on my own. I realized early on that using pointers or smart pointers is wrong, as it leads to ...
PavelDev's user avatar
  • 131
3 votes
2 answers
377 views

Prime numbers iterator

I am not familiar with iterators. I am confused with the traits approach and the traditional one. I don't know which one I should use in 2021. I wrote a minimal ...
nowox's user avatar
  • 1,099
7 votes
1 answer
300 views

Custom implementation to provide an immutable range of a container without copying it

I needed to pass a const reference to part of a std::vector without copy. I posted the previous version in my earlier question, thank you for the great support! As ...
Dávid Tóth's user avatar
1 vote
2 answers
103 views

Is there a way to simplify getting the character that appears the most in a collection with Linq?

I have a collection of strings, all of which are three characters in length: ...
Hazel へいぜる's user avatar
2 votes
1 answer
1k views

Python script to automate the creation of Linux LXC containers

Like the title suggests, I wrote a script in Python that uses the python3-lxc library to automate the creation of Linux LXC containers. I realised that containers ...
Aleksey's user avatar
  • 173
1 vote
1 answer
766 views

A multi key/value type "folded" map class template

I have recently come across a use case where I need to lump many maps into a single container. These maps can have different combinations of key/value types, but they all differ from one another. For ...
Emerald Weapon's user avatar
1 vote
1 answer
74 views

R Container for Multiple data.frame with a Brief Description of the Content of the data.frame

For a project I have a large dataset with a multitude of variables from different questionnaires. Not all variables are required for all analyses. So I created a preprocessing script, in which subsets ...
SysRIP's user avatar
  • 13
5 votes
2 answers
2k views

Hash table implemented in C with open addressing

While posting this, I noticed there are quite a few similar C hash table implementations here already. So I figured one more wouldn't hurt. :-) In any case, I'm writing a teaching article on "how ...
Ben Hoyt's user avatar
  • 609
3 votes
1 answer
343 views

Take element of a Set collection depending on the value of another element

I had to populate the fields of a Service object using a Set (HashSet) with any configuration parameters -> ...
jpestana's user avatar
2 votes
1 answer
41 views

An exercise concering Kotlin Set

Task description: Declare a function twoInThree(a: Set, b: Set, c: Set), which returns the set of all elements, which are contained in exactly two of the three given sets a, b, c. My solution: ...
michael.zech's user avatar
  • 4,282
4 votes
1 answer
103 views

Data set with many variables in Python, many indented dictionaries?

I am working with a data set that has many variables. Currently I am storing the data in many indented dictionaries in the following way: ...
user171780's user avatar
2 votes
1 answer
891 views

Generic hashmap with dynamic resizing and collision handling

This is a (more or less) continuation of a previous post I made: Generic implementation of a hashtable with double-linked list. I got lots of valuable feedback, so I decided to rewrite the entire ...
766F6964's user avatar
  • 901
4 votes
2 answers
874 views

C++20 "FixedArray" Container (dynamically allocated fixed-size array)

I've wrote a FixedArray to fit seamlessly (function-wise) with the default C++ containers, including working with algorithms/etc. It is a dynamically allocated, but fixed size array. Code ...
Ricardo Silva's user avatar
2 votes
1 answer
119 views

Print the App Name Using Latest Version

I am trying to solve a problem, where we are given an app name, service name, and version number of an api. We need to print the name of app, which is using the latest version for most of the service. ...
vikash srivastava's user avatar
2 votes
1 answer
929 views

Generic Doubly Linked-list implementation in C++

I am just learning about C++ templates and generic types, I decided it would be nice to try to create a generic container class as a challenge and test my knowledge in the process. Here is what I have ...
user avatar
10 votes
2 answers
129 views

Using Method Chaining To Alter Last Item Added To Collection

There is a Name class with properties that represent different components that make up a person's name. A Name object requires a FirstName and ...
John Steed's user avatar
5 votes
1 answer
3k views

Java group list of maps by value and insert as grouped list

Not sure if I am overcomplicating the requirement but this is what I need (for simplicity I will show a the List<Map<String, Object>> as a ...
user avatar
1 vote
1 answer
130 views

Dictionary or custom Collection

I have a list of rule names coming from .xml file. These rule names needs to be validated against rule names in database (Validator.cs). If valid, then ...
iniki's user avatar
  • 335
1 vote
0 answers
1k views

Implementation of Doubly Linked List with sentinel in C++ trying to replicate the stl std::list [closed]

I am currently trying to replicate the STL std::list interface with my own list implementation (doubly linked list with sentinel) to learn about all the advanced ...
Julian Aßmann's user avatar
1 vote
2 answers
80 views

Class template, custom container

So I wrote this class template for a custom container. Basically, it stores elements and their occurences. When an element is pushed into the container, if it ...
Khanoa's user avatar
  • 35
5 votes
4 answers
883 views

Reviewing custom array List class of java

I am using JDK 12 and I have developed the custom array list in java with a basic understanding Please let me know if there are any flaws in it that I can correct the same First the POJO class <...
dghtr's user avatar
  • 287
1 vote
4 answers
125 views

Get a random member of a container

It was not obvious how to get a random member of a container. So I wrote a function to retrieve it given a generator. ...
Martin York's user avatar
  • 94.6k
3 votes
2 answers
1k views

Adding/removing songs to a playlist

This is a simple Java application, which adds songs to a playlist, removes songs from playlist based on indexes. A database is not used in this. I am creating dummy data through a ...
kulsin's user avatar
  • 201
2 votes
2 answers
2k views

C++ ring buffer using some C++ 17 and coming C++ 20 std::span

When I heard about the new Linux I/O interface io_uring I searched about the ring buffer. I then thought I may replace my safe queue which is base on C++ 11 ...
dev65's user avatar
  • 313
3 votes
1 answer
92 views

Container that holds objects of various types, and can be searched for an object convertible to a given type

I built a container that can hold objects of various types, and look up an object convertible to a given type. I wrote something about my intended use-case here: https://stackoverflow.com/questions/...
Daniel McLaury's user avatar
5 votes
1 answer
157 views

Code to pick buckets for a list of value

In my current project, I came across a scenario where there will be two sorted list of Decimal values. Let's call them ...
Sab's user avatar
  • 151

1
2 3 4 5
7