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
1answer
41 views

Print the App Name Using Latest Version

I am trying to solve a problem. Where we are given with app name , service name , version number of api we need to print the name of app which is using the latest version for most of the service. <...
2
votes
1answer
324 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 ...
3
votes
1answer
2k views

vector<tuple<A,B> > to map<A,B>

i have an vector<tuple<A,b> > v and want to make a map<A,B> from it i came up with 3 variants: ...
10
votes
2answers
109 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 ...
4
votes
2answers
786 views

Implementing an HotelManager interface in Java

Got a mission to implement an Hotel Manager interface. I will post the interface and the attached class Reservation, and will add my code. What I am asking you is ...
5
votes
2answers
177 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 ...
9
votes
2answers
7k views

Thread-safe LRU Dictionary in C#

Can't seem to find one, so trying to build a very simple but fast implementation. Thought I would post on SO for review/feedback, and so that others can just copy/paste for their own use. I'm using a ...
2
votes
1answer
105 views

Python: rearranging data collection

Let's say I have a data collection, like a list, containing a set of objects with particular properties. Let's go with animals: [ cow, sheep, orangutan ] An animal ...
1
vote
1answer
2k views

Regrouping list by nested groups

I have a list of units (as in entities in a game): workers = [engineer1, engineer2, scientist1, scientist2] These workers have a couple of properties I want to ...
1
vote
1answer
51 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 ...
2
votes
0answers
302 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 ...
1
vote
2answers
57 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 ...
2
votes
1answer
96 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: ...
5
votes
4answers
657 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 <...
1
vote
4answers
104 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. ...
3
votes
1answer
1k views

BTreeMap as a multimap in Rust

I'm learning Rust so as an exercise I'm trying to write a datatype wrapping the builtin BTreeMap to allow it to store duplicates. Like the STL multimap type. The ...
2
votes
1answer
201 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 ...
3
votes
2answers
136 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 ...
11
votes
2answers
173 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 ...
8
votes
3answers
1k views

Moving elements satisfying a predicate from one container to another

I've implemented a C++ algorithm that moves elements satisfying a given unary predicate from one container into the other, deleting them from the input container. This is my implementation: ...
3
votes
1answer
68 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/...
9
votes
1answer
223 views

Binary Search Tree Implementation in C++17

I am a hobbyist computer programmer trying to learn modern C++ (in this case C++17). I thought it might be an interesting challenge to write a Binary Search Tree similar to ...
12
votes
2answers
14k views

Ring Buffer Implementation in C++14

A ring buffer or circular buffer is a fixed sized queue that advances head and tail pointers in a modulo manner rather than moving the data. Ring buffers are often used in embedded computer design. ...
2
votes
0answers
62 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 ...
5
votes
1answer
143 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 ...
4
votes
1answer
232 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 ...
5
votes
1answer
118 views

Data structure that is fast to read and modify

I'm working on an apllication that needs to process a lot of objects in realtime. I've separated the logic from the UI so that it isn't as much of a mess. The basic idea is that every tick I'm trying ...
5
votes
3answers
1k 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: ...
10
votes
2answers
1k 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#, ...
2
votes
2answers
898 views

Set, List and Map equality comparison with Lambda check

I'd like to be able to compare two objects with different equality checks. This should work if they're in a Set, List or ...
1
vote
1answer
195 views

Extension to BindingList<T> that allows for cancelable notifications of changing and deleting

This is an extension of the System.ComponentModel.BindingList<T> class that allows for notifications of item changing and deleting. These notifications ...
3
votes
1answer
275 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 ...
0
votes
2answers
94 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 ...
4
votes
0answers
60 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 ...
1
vote
1answer
173 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 ...
8
votes
3answers
9k 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 ...
6
votes
1answer
195 views

Overlapping table fragments

One of my side projects is a table driven scanner/parser generator, in an effort to reduce the size of the transition table I represent the generated table A[x, y] ...
5
votes
2answers
598 views

Chunking a list into separate lists of 5, and then iterating through each

I'm writing a service that receives a list of Latitude/Longitude objects, prepares them for transaction, and then calls a web service to write them to the organization's Mainframe. According to the ...
4
votes
0answers
96 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 ...
2
votes
1answer
88 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 ...
2
votes
2answers
104 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: ...
4
votes
2answers
304 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 ...
3
votes
2answers
5k views

How to observe nested objects

By having two model classes Conversation and Message, what are the best practices to handle the next situation: A conversation ...
3
votes
0answers
39 views

Dependency Container

I'm currently creating my own microframework for learning purpose and I want to make it more powerful by providing a way to register classes and instantiate them (once) only when needed. So here is my ...
9
votes
1answer
197 views

Class containers, filtering and coding practices

Context Usually, when I have to deal with a collection of items (especially objects) I tent to create a container class for that collection (wrapper?). What I mean by that is: when I have to handle ...
2
votes
0answers
78 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 ...
3
votes
1answer
95 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 ...
2
votes
1answer
638 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 ...
17
votes
2answers
2k views

O(1) lock free container

This is a lock-free Container class. By Container I mean it will hold objects for iteration at a later time. To achieve \$O(1)\$ ...
3
votes
2answers
175 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 ...

1
2 3 4 5
7