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
1answer
50 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
89 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
55 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
649 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
101 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
129 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
104 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
201 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 ...
10
votes
2answers
10k 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
228 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
115 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
959 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
868 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
144 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
242 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
93 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
159 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
512 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
89 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
54 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: ...
3
votes
2answers
227 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 ...
2
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
38 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 ...
8
votes
1answer
189 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
75 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
90 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
443 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
154 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
vote
1answer
72 views

Wrapper for a standard STL-container

In the codebase I support, I found the following code. I am interested in your opinion about its expediency and especially the expediency of redefining the operator(). ...
9
votes
2answers
3k 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 ...
6
votes
3answers
6k views

Find a prefix of a query string in the values of a Map

I have a hash map which maps to some strings which serve as prefixes and are of small length (max length is 6): ...
1
vote
0answers
73 views

Further dive into filtering using IPredicate

Preface This is a follow up to my previous post from not long time ago about containers and filtering. This post can be found here. Now, I will attempt to expand what I have learnt from the answer ...
4
votes
3answers
158 views

My implementation of a for_each function that traverses a std::container by some step size integer N

As my answer to Iterating over an odd (even) elements only in a range-based loop, I wrote this function, with the following driver program and output: ...
2
votes
0answers
88 views

Simple generic macro-generated containers

In order to learn macros in C I decided to make a generic data structures generator for other projects that I have in C. The main macros are the following: ...
4
votes
3answers
619 views

Pass IEnumerable<T> as an argument of method and repository pattern

I've seen tutorials of Unit Testing and I've never seen that IEnumerable<T> used as an argument of method. All authors use ...
0
votes
1answer
98 views

java.util.Set extension/implementation

Lately, I was working on some experimental java.util.Set extension, IdSet: ...
0
votes
1answer
75 views

Breaking a 32-bit value into bytes for an ArrayList

I am very new to Java and its collections and I'm trying to figure out "best" way to populate an ArrayList<Byte> in Java. In particular, I'm trying to take a ...

1
2 3 4 5
7