All Questions
Tagged with java-collections-api or collections
24,165 questions
Advice
0
votes
2
replies
60
views
Collection with fragmented index
I want to map a DB-table into a Java collection object. Important for me is a numerical index IDX and some other data, e.g. a STR.
IDX STR
1 Max
2 Sam
4 Tom
7 ...
1
vote
1
answer
47
views
How to bind viewmodel collection to dynamically-created ItemsControl in code?
In my Avalonia app I have a user control (UC) that has some databound controls and a StackPanel that has controls added to it dynamically from code-behind. This UC is then dynamically added to an ...
0
votes
2
answers
175
views
Cannot get TList<>.Sort() to work in Delphi 11 FMX
I have been trying to sort a collection of objects. While I have seen many promising solutions, my compiler simply won’t accept them (error message in procedure GenReorderSpeciesList). I am using ...
0
votes
0
answers
44
views
Would it be a good practice to make Talkback read all the items in a lazy row automatically?
Is it a good practice to make Talkback read all the items in a lazy row automatically?
For example, user focuses in the first item of the lazy row, talkback reads the whole item, and the move on to ...
1
vote
3
answers
145
views
Excel VBA - Is It possible to merge 2 ObjectLists
I have a For Each loop that I'm trying to use with a
For Each objs In Sheets("Categories").ListObjects
Blah blah blah
Next
This works fine. The problem is that there is an outlier ...
-3
votes
2
answers
69
views
Update collection from manual entered gallery details in power aps
I'm getting a filtered record set from a SharePoint list to a collection, and then I'm getting that collection data to a gallery. In the gallery, I have added a text input. If we think, for example, ...
0
votes
2
answers
172
views
Why does Collectors.toMap() throw NullPointerException when mapping to null values? [duplicate]
I'm trying to convert a List of Products to a Map<Long, String> using Java streams. My goal is to collect the DTOs into a map where the key is getId() and the value is getLogoPath(). The ...
1
vote
2
answers
60
views
Reading collection data into Oracle cursor
I created two types as follows:
CREATE OR REPLACE TYPE t_emp AS OBJECT (id NUMBER, name VARCHAR2(100));
CREATE OR REPLACE TYPE t_emps AS TABLE OF t_emp;
Then I have the following PL/SQL block:
...
0
votes
2
answers
80
views
conditional map fetch efficiently
I have a map which lays down prices of commodities in different currencies
val commpricemap: Map[String , Map[String, Double]] = ???
AN example of an entry for gold is as below:
("AU" -> ...
0
votes
1
answer
111
views
Can we traverse stack in FIFO order without custom logic?
My teammate asked if we can traverse stack in FIFO (First In First Out) order. I say stack itself maintain LIFO order in it but we can traverse it in FIFO manner by using another stack or list. Then ...
1
vote
1
answer
113
views
Avoiding redundant else
class Person( id:String , age:Option[Double])
val rows: Seq[Person] = List(Person("a",None),Person("c",None),Person("e",50))
val ages = rows.foreach( r => r.age ...
1
vote
3
answers
120
views
Optimizing linear search in Scala
I implemented a following algorithm:
val acceptedTopics: Set[String] = ...
val arr: List[JValue] = ... // JValue is an algebraic trait extended by JString, JInt, and other types.
val topics = arr....
1
vote
2
answers
93
views
Filter an optional sequence
I have a Option sequence of dates - from which I need to SAFELY extract the first date after a given date( or else return the given date).
The below seems to be a lot of code for such a simple used ...
8
votes
1
answer
212
views
How to validate rectangle positions in a repeated 4-role layout with axis-based spatial constraints?
I'm working with a list of rectangles and need to validate whether each one is in the correct position based on a fixed pattern and a set of geometric constraints.
In the input list there can be any ...
0
votes
2
answers
132
views
How do I compare two lists of objects in C# where a field matches for all rows
I have two lists of the same object type with the columns:
CustomerID
ProductID
33, 120A
33, 240B
33, 14CD
33, 984A
34, 120A
34, 240B
35, 14CD
35, 984A
39, 120A
39, 240B
39, 14CD
39, 984A
How can I ...
4
votes
1
answer
127
views
State flow doesn't emit new value when sorting a Map
I’m using Jetpack Compose with StateFlow in a ViewModel. I have a Map<String, List<Int>> and I want to sort it by the size of each list, then display the sorted result in the UI.
Inside my ...
2
votes
1
answer
71
views
Return collection in Milvus. How to undo `recreate_collection`?
I have a standalone Milvus running in docker. It is recording vectors into volumes folder.
I accidentally ran recreate_collection command and now it show there is no data in collection. Though, the ...
1
vote
1
answer
60
views
Retrieving attribute from a entity collection conditionally
class Employee(id: String , name: String, dept: Option[String])
Given a collection of employees , I need to return the collection of depts - given a set of id.
employees.filter( if ( ids.contains( _....
0
votes
0
answers
20
views
Load factor of IdentityHashmap in JDK 8 and JDK 9 to current JDK
I Came to know the loadfactor for Identity Hashmap is 2/3 in jdk8 , but in jdk 9 to current version the loadfactor and resizing changed in put method . Can any one explain this exactly
Jdk 8 : https://...
0
votes
1
answer
88
views
list(collection.find()) Not Returning any data in Python
import json
from flask import Flask, jsonify, request
from kafka_producer import send_user_query_to_kafka, send_business_rules_to_kafka
from kafka_consumer import consume_and_process
from pymongo ...
0
votes
1
answer
100
views
java hashmap or List for aggregate function
I have result set data coming back from DB as follows:
Input looks like this. Its an arrayList
id year name rank Subj Marks
1 2025 name1 A Science 90
1 2025 ...
0
votes
1
answer
76
views
Mapstruct - Mapping nested objects having array?
Input
I have these PageAndData object as Targetmapstruct
public class PageAndData {
Page page;
List<Data> data;
}
public class Page {
private int size;
private int totalPages;
}
...
1
vote
1
answer
84
views
Transform a sequence of strings containing delimiter
I have a sequence of strings which may or may not contain a delimiter
val words = Seq("1 $ cake", "2biscuit", "3brownie", "4 $ honey")
I would need to create a ...
3
votes
1
answer
158
views
How can I process elements in reverse order across different collection types?
The "Sequenced Collections" feature in Java 21+, introduced in JEP 431, provides a uniform way to handle collections with a defined encounter order. How can I leverage this feature to ...
0
votes
1
answer
147
views
How to group anagrams using collections efficiently? [closed]
I'm working on a Java problem where I need to group words that are anagrams of each other. For instance, given the input array:
["eat", "tea", "tan", "ate", &...
0
votes
1
answer
47
views
Grouping By Child Class into Map
I had made a list of Parent Class (as Employee) having a parameter of child class (as Department)
class Employee {
Integer empId;
String empName;
Long salary;
String email;
...
1
vote
2
answers
79
views
how to find from map with default values for failures
I have a sequence of Students
val students = Seq(Student("Roy"),Student("James"),Student("Rita"))
Have a map of student to marks
val myMap = Map(Student("Roy") ...
0
votes
1
answer
266
views
Laravel Collection how to access a given index?
I am new to laravel collections. How can i iterate to retrieve all the elements from the itens index ?
If i var_dump the $result i see the output below :
var_dump($result);
object(Illuminate\Support\...
0
votes
0
answers
106
views
PineScript Loop through collection of inputs
For PineScript V6
Goal:
To loop through all of the inputs assigned to a specified group, then perform specific actions based on the value of each input in that group.
I know I can build a custom array ...
0
votes
1
answer
76
views
How do I merge two Azure SQL data sources?
I have two tables with 1..* relation:
Table 'Product'
Id
Name
1
Product 1
2
Product 2
Table 'ProductVersion'
Id
ProductId
Published
10
1
1
11
1
0
Now I want to merge these data sources in Azure Search ...
0
votes
0
answers
57
views
Converting a jsonString to HashMap
I have a jsonString which is a list of key value pairs.
[
{"id": "123", "url": "ghi"} : 2,
{"id": "456", "url": "def"} ...
2
votes
1
answer
91
views
JwkSet gives Cannot resolve constructor 'JWKSet(List<RSAKey>)' - Stream.collect(Collectors.toList()) vs Stream.toList()
In our code, we use JWKset from the nimbus-jose-jwt library in a method that creates a map that we use for stuff. As you can see in the return, we use a stream that calls map on a list of RSAkey, and ...
4
votes
1
answer
131
views
How to clear VBA Collections Faster?
I am using collections in my VBA code to store objects (which also contain collections inside), and I am having issues with the time it takes to clear the collection (there are around 10,000 records, ...
0
votes
1
answer
81
views
I am trying to streamline a Userform controls collection to hold only ComboBoxes. How do I delete controls from the controls collection?
Everything looks good in the watch window until the Remove instruction is executed.
No help to reverse the loop to step -1 from the end.
' ---------------------------------------------------------
' ...
0
votes
0
answers
35
views
How do I remove an item from an ms-forms Collection in Excel VBA [duplicate]
' ---------------------------------------------------------
' Remove non-ComboBox controls from the controls collection
' ---------------------------------------------------------
Public ...
1
vote
1
answer
63
views
Is there a way to make a collection class of a single element class?
Assuming I have a python class A, is there a way to make a class A_Collection such that any attribute of or function applied on A can be apply to A_Collection which pass down to its individual ...
0
votes
1
answer
111
views
What is the difference between these patterns?
The pattern [] only matches empty lists, while [_] only matches lists with exactly one element ([_,_] for exactly two elements and so on).
So far it is logical for me.
But it seems the patterns [..] ...
2
votes
3
answers
273
views
What does this piece of code mean? new ArrayList<>(Collections.emptyList())
In some code from my company, I've read a list initialization:
List<SomeClass> someClassList = new ArrayList<>(Collections.emptyList())
What does it mean? A list with 0 size ...
-2
votes
4
answers
212
views
What is difference between Hashmap.get(0) and Hashmap.get(0L)? [duplicate]
I have:
HashMap<Long, MYChainInformation> CHAIN_INFORMATION = new HashMap<>();
When I use this pattern to get element at index 0:
MYChainInformation MyData = CHAIN_INFORMATION.get(0);
...
1
vote
0
answers
148
views
Eleventy pagination - how to create pages sorted by fields in a data collection
JSON or JS file in the eleventy _data folder of the form
{
ID: 149,
Year: '1901',
Last: 'Thompson',
First: 'Will',
Middle: ''
}
etc ...
creates a large eleventy collection
I am able to ...
0
votes
1
answer
90
views
Is there a better way to sort a list of custom type in C#? [duplicate]
Scenario
I am making a prototype TCG project in Unity3D. I have a list of custom type CardDetails.
List<CardDetails> cards;
CardDetails.cs includes attributes of card like following.
public ...
-7
votes
1
answer
73
views
Need to group by list of list in pojo in java and sort by year and month
We are getting list of AssetValue from database,
After getting the list I need to group by id and sort by year and month.
Based on the grouping I need to print on reports.
Public Class AssestValue{
...
-1
votes
1
answer
50
views
Removing an element from an array by index corresponding to the index of an element removed from another array
There is ia part of the document of the collection Collection1 in MongoDb.
"array1": [
"060030909",
"200",
"32004"
],
"array2": [
"aaa&...
0
votes
0
answers
34
views
Laravel sort by issue [duplicate]
I am having issues trying to sortBy on a collection which contains a custom mapped field when transforming a collection.
public function getCentres(Request $request, string $id)
{
$...
0
votes
0
answers
36
views
memGraph Lab Collections
In memgrap LAB, I lose all my saved requests in collections when I log out.
What should I do?
I have tried exporting all my queries through the export collection feature. However, the import cannot be ...
1
vote
3
answers
127
views
Adding Elements to a KeyValuePair<X, Y>
I looked at this answer, and it appears the response may be "you can't get there, from here," but I have to try...
I am building a dynamic SwiftUI Charts generator, and need to figure out ...
2
votes
3
answers
168
views
No result when filtering on a random IntStream, in Java
I am representing a collection of turtles, each with a moment when hatched. I want to randomly choose any mature turtle.
I pretend that minutes are years, in this aquarium simulation.
record Turtle(
...
1
vote
3
answers
138
views
how to order a collection
here is what I've been working on:
I have a list of numbers for example [1,2,3,4]
At each step I can add or substract x to a number of the list
A particular case is if the element becomes 0, then you ...
0
votes
3
answers
84
views
DataTable.ToList() raises collection was modified exception
My application modifies certain DataTable from multiple threads. I have already implemented exclusive locking mechanism for adding rows and committing to DB (2 different threads were handling it). Now,...
0
votes
2
answers
42
views
Flutter - Grouping a list of Objects on Common String Value
I have this Group object
class Group {
final String dateFormatted;
final List<Event> events;
Group({required this.dateFormatted, required this.events});
}
I need to ...