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
1 vote
1 answer
51 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 ...
user avatar
0 votes
1 answer
63 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 ...
user avatar
  • 2,227
0 votes
1 answer
85 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: ...
user avatar
  • 301
5 votes
1 answer
198 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 ...
user avatar
  • 53
5 votes
2 answers
138 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 ...
user avatar
  • 2,227
1 vote
0 answers
105 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 ...
user avatar
  • 53
-1 votes
1 answer
55 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 ...
user avatar
0 votes
1 answer
53 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 ...
user avatar
3 votes
1 answer
67 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 ...
user avatar
  • 171
3 votes
0 answers
144 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 ...
user avatar
  • 131
3 votes
2 answers
159 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 ...
user avatar
  • 933
7 votes
1 answer
200 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 ...
user avatar
1 vote
2 answers
92 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: ...
user avatar
2 votes
1 answer
298 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 ...
user avatar
  • 79
1 vote
1 answer
54 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 ...
user avatar
1 vote
1 answer
40 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 ...
user avatar
  • 13
5 votes
2 answers
922 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 ...
user avatar
  • 519
3 votes
1 answer
337 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 -> ...
user avatar
2 votes
1 answer
35 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: ...
user avatar
  • 3,758
4 votes
1 answer
96 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: ...
user avatar
2 votes
1 answer
306 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 ...
user avatar
  • 795
3 votes
1 answer
142 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 ...
user avatar
2 votes
1 answer
69 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. ...
user avatar
2 votes
1 answer
809 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
113 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 ...
user avatar
5 votes
1 answer
2k 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
64 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 ...
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 ...
user avatar
1 vote
2 answers
63 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 ...
user avatar
  • 35
5 votes
4 answers
750 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 <...
user avatar
  • 287
1 vote
4 answers
107 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. ...
user avatar
  • 91.5k
3 votes
2 answers
666 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 ...
user avatar
  • 201
2 votes
1 answer
1k 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 ...
user avatar
  • 293
3 votes
1 answer
75 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/...
user avatar
5 votes
1 answer
147 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 ...
user avatar
  • 151
5 votes
3 answers
2k views

reverse a list of generic type

Q: Given a list, reverse the order of its elements (don't use collections). Here is my solution: ...
user avatar
2 votes
1 answer
98 views

transform list to array

Q: Write a method that transforms a list into an array (don't use collections or already implemented methods in lists, make your own method) I've come with this solution: ...
user avatar
10 votes
2 answers
2k views

IList<T> implementation

I was wondering about the possibility to create an implementation of IList<T> that is faster than List<T> using C#, ...
user avatar
3 votes
1 answer
334 views

LinkedList Swift Implementation

Linked List Implementation in Swift Swift 5.0, Xcode 10.3 I have written an implementation for a doubly linked list in Swift. As well, I decided to make the node class private and thus hidden to the ...
user avatar
0 votes
2 answers
677 views

A java program that gets a key-value pairs from a textfile, which should also print in a matrix/table like [closed]

I just want to get some advice about code optimization. How can I make this more OOP? How many class should I have for this kind of task? My code already works but I was told to use OOP in a way that ...
user avatar
  • 17
4 votes
0 answers
70 views

C++14 AtomicRoundRobinPool for sharing a pool of keys

The idea here is that we have some resource that is relatively very expensive to generate, but once we have a bunch of them in a pool, we can keep reusing them instead of generating new ones. "HTTP ...
user avatar
1 vote
1 answer
403 views

Fast insert, fast removal and fast access object pool C++ container

I just want to gather some feedback about this container, in my view it solves the problem of common data containers which don't have fast access and fast deletion. I want to admit that I have not ...
user avatar
  • 245
4 votes
2 answers
621 views

A polymorphic union in C++

Sometimes I use std::unique_ptr<BaseClass> when all I really want is polymorphism. For fun, I made this container that skips the heap allocation. The ...
user avatar
4 votes
0 answers
114 views

Generic Macro Generated Interval Heap in C

When I saw this amazing data structure I couldn't stop myself from trying it! I first sought resources such as this and an article about it here. It basically works as a Max-Heap and a Min-Heap at the ...
user avatar
  • 347
2 votes
1 answer
232 views

Force ConcurrentDictionary in a Singleton Registry to Collect Removed Items/Space

I have the following class which is used in a WebApi AspNetCore application as a singleton instance to store Strategy objects (reference type). The class is ...
user avatar
2 votes
0 answers
88 views

Game involving finding words containing letters from a memorized list

I wrote this Java game where the user memorizes a list, gets given letters and needs to find a word that contains those letters. The player has only a few seconds to enter the word. Example: Program ...
user avatar
3 votes
1 answer
122 views

Generic Macro Generated Hashset in C

The Hashset uses open addressing, linear probing and Robin Hood hashing for handling collisions. It comes with insert and remove ...
user avatar
  • 347
2 votes
0 answers
63 views

Iterating in a list of data and search data in another datatable

I have a list which has 25000 data and I am iterating in all data and in each iteration, I am searching data in another data table. my whole routine is taking a long time to finish. Loading data from ...
user avatar
2 votes
1 answer
1k views

Generic Macro Generated Linked List in C

Generate a linked list of any type using macros. The linked list contains functions for adding and removing elements to both ends and also at the middle. You can also add elements relatively to a list ...
user avatar
  • 347
3 votes
3 answers
417 views

Efficient way of flat mapping a range of a multidimensional random access collection

I've recently answered a question about reading elements from an array of arrays. A way it could be interpreted is that the OP wanted to read a range that could span over multiple subarrays of the 2D ...
user avatar
  • 857

1
2 3 4 5
7