Questions tagged [collections]

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

Filter by
Sorted by
Tagged with
3 votes
2 answers
75 views

AbstractList guarantees that spill into other methods

I can't think of a better name for the question, but I hope that an example will make this simpler. Suppose I create my own custom List (it is irrelevant what it does): static class MyList<E>...
Eugene's user avatar
  • 118k
-2 votes
1 answer
37 views

Concurrent HashMap default segment value?

What is the default number of segments in a ConcurrentHashMap in Java? How does it affect the concurrent performance of the data structure? Can I customize the number of segments, and if so, how do I ...
Amar kumar Nayak's user avatar
1 vote
2 answers
60 views

Java generics and collections: Why it is possible to assign float list to List<? super Integer>?

In Java generics topic stated, that expression `? super Integer` means any type(class) that has Integer as super class(Including Integer.class). Then why following behavior possible? List<? super ...
Dmitriy Vasilyev's user avatar
-3 votes
0 answers
13 views

Same key needs to push into array from collection [duplicate]

I am working in react latest version.I have a collection data = [{id:1, name:3},{id:2, name:4}] . I want to push all id value to new array . The result should look like this [1, 2].
anu's user avatar
  • 11
-3 votes
0 answers
22 views

find common in three arraylist? [closed]

find common in three arraylist using java So the one way is convert arraylist to array using Object a[]=a1.toArray(); but i find another way of doing this program. Way to look a basic or ...
Ambarjeet Chaudhari's user avatar
1 vote
0 answers
54 views

Java Map with Multimap values - how to efficient split the true entries from the false ones

I have a Map made up of this structure Map<String, Multimap<Boolean, String>> . I want to separate all the true entries in one new map and the false ones in a second. I have the following (...
Timothy Clotworthy's user avatar
0 votes
1 answer
40 views

How to Use CollectEntries in Groovy to create a map that has multiple values for each key

I have the following List of Lists. It is in the format of [String, Double] def data = [ ['A', 15.2], ['A', 14.7], ['B', 6.54], ['A', 4.5], ['A', 16.8], ['A', 7.7], ['C', 1.5], ['B', 13.1], ['B', 6], [...
snbmt21's user avatar
0 votes
0 answers
5 views

Passing both generic list and different types of elements(char, bool, int ) to a single method in java

public class IteratorExample { public static <T> void main(String[] args) { List<T> tList = new LinkedList<>(); addDataToList("First Element", tList); ...
Ravi Bansal's user avatar
0 votes
0 answers
9 views

wix velo : using a dropdown menu to navigate to another item of a collection

I created two dynamic pages linked to an "ACTIVITIES" collection. The 1st is general, it lists all the activities. The 2nd, ACTIVITIES-Item, details the characteristics of each activity, ...
isyvon's user avatar
  • 1
0 votes
0 answers
14 views

How to extend Eloquent Collection for use with mezzio-hal?

I have a Collection with paginator, _links and _embedded keys, which response using it and mezzio-hal looks like this: { "_total_items": 20, "_links": { "self": { ...
dearmisterrobot's user avatar
0 votes
0 answers
28 views

Meteor/Vue: Display result of search

I would like to add a search field to my app and show all articles from my Collection that match the entered value. The searchArticles method is called but the values are not shown as defined below ...
AntonSack's user avatar
  • 1,021
0 votes
1 answer
37 views

Kotlin sorting generic collections

I have some inline function for filtering query data, like this: inline fun <reified T> findByFilterFunc(filter: String, em: EntityManager, offset: Int, limit: Int, sortName: String?, ...
dtadescu's user avatar
1 vote
2 answers
42 views

Iterate through rows in data frame with n rows and n columns and count the frequency of combinations 1:n

Iterate through rows in data frame with n rows and 6 columns and count the frequency of combinations 1:n within each row. Non working template code: import pandas as pd import itertools from ...
RTrain3k's user avatar
  • 857
0 votes
1 answer
71 views

C# syncing two lists that are accessed by two different threads

I have a list of objects in a game that may or may not run complex collision testing each multiple times per second. Because this collision testing is quite expensive each object has a list of ...
AudioGuy's user avatar
  • 423
0 votes
1 answer
46 views

How to define a "Collection of String" property in UserControl using WinForms in VB.NET?

I try to add a collection of String to a UserControl that I defined in VB.Net using Winforms. The code of collection's property is following Private oItems As New StringCollection 'StringCollection '...
schlebe's user avatar
  • 3,493
0 votes
1 answer
59 views

Prevent IReadOnlyCollection<T> to have default item

Is there an immutable collection that prohibits initialization with default values? For instance: var newObjects = new MyObject[] { default } The MyObject class has a Copy ...
Steffen Skaraas's user avatar
0 votes
0 answers
107 views

eclipse fails to display collection elements in debug mode with error message "The method toArray() is undefined for the type Collection___"

I experience problems when debugging in eclipse. Similar issues are described in a post from more than 4 years ago. It is reported to be solved by some more recent versions of eclipse (STS) but ...
r-uu's user avatar
  • 433
-1 votes
0 answers
32 views

JAVA 8 Parallel Streams - Compare 2 Lists and get a different list [duplicate]

I am looking for a better solution/suggestion which is high in performance. I have the below use case Compare 2 lists. List A and List B. Both lists contain List of Car objects. I have to check if ...
tinku's user avatar
  • 25
0 votes
0 answers
23 views

columns and type attributes are not functioning as expected in the @CollectionId annotation in Hibernate

I am currently working with Hibernate-core ORM version 6.3.1.Final. It appears that when using collections in a class, the columns and type attributes do not seem to function as expected within the @...
Andro hub's user avatar
0 votes
1 answer
28 views

Jaxb marshalling with nillable = true on collection do not work

I've got DTO: @Builder @NoArgsConstructor @AllArgsConstructor public class MyData { private String payload; @Data @Builder @NoArgsConstructor @AllArgsConstructor @...
Ytug Ilya's user avatar
0 votes
2 answers
50 views

Kotlin - Using Subtract and Intersect without mapping and using Find

Take the following code below in the function. I have a data class of titleDto as a list and a list of existing titleIds. I use the subtract and intersect methods to find what data is unique and ...
Calum Templeton's user avatar
-2 votes
0 answers
19 views

errro r : The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all() [duplicate]

key = key of a dictionary (eg. {52: [132]}) if df[(df['{column name}'].isin(key)): print("D") we have 132 in the df['{column name}'] but when I run it, it says The truth value of a DataFrame ...
PR13's user avatar
  • 1
-1 votes
1 answer
158 views

Accessing Element In linkedList [duplicate]

LinkedList<String> linkedList = new LinkedList<>(); linkedList.add("Java"); linkedList.add("Python"); linkedList.get(1); Internal code flows for get public E get(int ...
Er Rahul Raj's user avatar
0 votes
2 answers
52 views

Data output via the Laravel API for a grouped collection

My problem is that I can't bring the output of a list of products grouped by category, for further deserialization in an iOS application using the Decodable protocol. In my Laravel 10 application ...
Kastorsky's user avatar
0 votes
0 answers
45 views

Filter a map to have only the given set of keys

I have a Map<K, V> named myMap, and a List<K> named myList. I want to create a submap containing only those entries whose keys are in myList. I can see the following ways: val newMap1 =...
k314159's user avatar
  • 6,299
0 votes
0 answers
16 views

How to redirect from '/collections/all' to '/collections/shop-all' with Liquid or JS from Shopify

I had a store on Shopify where I would like to know how can I redirect from '/collections/all' to '/collections/shop-all' with Liquid from Shopify. (But I already have read that you can't redirect ...
Tyler Tisdale's user avatar
3 votes
2 answers
71 views

How can I create a live sub-collection based on a predicate?

Background I have an interface public interface ThingRegistry { public Set<Thing> getAllThings(); public Set<Thing> getAllThingsWithProperty(String property); } And an ...
Scroobius's user avatar
  • 100
-1 votes
2 answers
63 views

How to Set Up '301 redirect' from '/collections/all' to '/collections/all/shop-all' on Shopify?

I'm just tryin' to set up a link as the '301 method', tryin' to redirect from '/collections/all' to '/collections/all/shop-all' on Shopify, where when I click from the 'Shop' button, it needs me to ...
Tyler Tisdale's user avatar
0 votes
0 answers
12 views

Making a unique column in React Js

I am facing a confusion in which I am trying to make my Team component in which I fill the form as a logged-in user and then create my team. But the way I created the table isn't very good idea. Below ...
Sohaib Ahmad Jamil's user avatar
0 votes
0 answers
12 views

IBM ODM rule designer comparing 2 collections items

So I want to design a rule that checks if the items in collection A are all in collection B. However, rule designer only lets me compare a SINGLE item form collection A with ALL items in collection B. ...
Usama Nadeem's user avatar
1 vote
1 answer
35 views

How to access a same cursor in multiple goroutines from mongo-driver go package

I am using multiple goroutines to read documents from cursor in MongoDB golang sdk. But its not returning all documents. Note: Its working correctly with single goroutine. I want to read all documents ...
Purushottam Hirave's user avatar
0 votes
2 answers
33 views

I need to sort a map which have around 100 key value pairs as "H":"Hector", "A":"Alpha" and so on, I need to sort first 10 in a specific order

Map<String, String> records = new HashMap<>(); HOSTING.put("H", "Hector"); HOSTING.put("B", "Bravo"); HOSTING.put("W&...
Vivek Pandey's user avatar
3 votes
2 answers
80 views

Java Collections: NPE even though no null value was ever added

I recently got an NPE in a context where I was absolutely sure it shouldn't be possible. The class is used in a very multi-threaded program, so I'm aware that you should expect basically anything to ...
slarti76's user avatar
0 votes
1 answer
51 views

how to make customized jexl function to work with collections

I tried many ways but seemed jexl doesn't work well with collections and lambda expression. Essentially I have a list of json objects and I want to have a customized utility function set into jexl ...
user2103145's user avatar
1 vote
1 answer
106 views

How can I speed up the counting of matching entries between two large arrays in Powershell?

I am trying to count the number of matching elements between two large Powershell arrays/collections generated by capturing Active Directory ("AD") data. However, it is very slow. Concept ...
DIV's user avatar
  • 65
-3 votes
0 answers
36 views

How to have ArrayList as values to HashMap [duplicate]

I'm trying to implement Graph data structure in java representing it as adjacency list. Im using Map<Vertex, List<Vertex>> as adjacency list. Here I cant able to add vertices into the ...
Sree Teja's user avatar
0 votes
1 answer
102 views

Does C# support collections of refs?

I'm learning about C# and had a question about its capabilities. I was looking to create a list of ref tuples. Example attempt using ints to keep it simple: // will not compile -- just to illustrate ...
quetzalcoatulus's user avatar
0 votes
1 answer
67 views

QueryDSL Collection contains

Simple QueryDSL code that searches for users with specific single role. It was working in the past (version findByUserRole_1()) and now I get exception after upgrading to the latest Hibernate. The ...
horvoje's user avatar
  • 693
0 votes
0 answers
20 views

Error adding elements into ArrayList after intialization [duplicate]

I have implemented Graph Data structure using Collections Framework as Adjacency List implementation in Java. I'm not able to add an edge using addEdge method defined below. Im getting ArrayList as ...
Sree Teja's user avatar
1 vote
1 answer
35 views

Why does an event with conditional is not being triggered?

I am trying to send a JavaClass from one agent to another. For this, I am first creating instances of that JavaClass in one event. That event runs at a rate of 1 per second in the simulation. The ...
Zainab's user avatar
  • 23
0 votes
3 answers
66 views

Collections.sort seems to generate incorrect results

The following code work except for specific inputs. For instance the following input, -1795085364 stay as the last value, despite being the smallest. I am using java 13. {306474574, 642543743, -...
 RichardFeynman's user avatar
0 votes
0 answers
48 views

Replacing `<span>`with text node: Is it a programmer error, or a browser error?

I'm trying to replace some placeholders in my HTML that look like <span id="Something" />. Using the following JavaScript code only replaced the first occurrence, and I wonder why: ...
U. Windl's user avatar
  • 3,627
0 votes
1 answer
49 views

If a new instance of collection is created inside a function is it thread safe?

I just read in C# collections are not thread safe, what if I create a new collection instance everytime inside a function as a local variable. Is it still not thread safe? public void AddToCollection(...
Ambareesh's user avatar
-2 votes
1 answer
38 views

Awaitable collection of reuseable resources

I have tried to search the web for this, but I didn't find exactly what I was looking for. I have a list of workers, that execute certain work. In order to execute this work, the workers need access ...
Bas Visscher's user avatar
0 votes
0 answers
36 views

Collection for many elements and multithreaded reading

There is a task in which it is necessary to subtract from the database a huge list of models (several millions) and, based on the data of each model, make separate calculations and save them in ...
Kerasss's user avatar
2 votes
2 answers
104 views

Java List has a method to add multiple elements at a position, but I can't find a method to remove multiple elements at a position

There is List.addAll(position, collection) but I can't find a corresponding List.<remove>(position, <range>), whatever the wording of and the way is specified would be. In ArrayList, ...
Markus's user avatar
  • 690
0 votes
0 answers
27 views

To get the exact amount of data between specific date range and insert in table in oracle plsql procedure using varray type collection

`I need to modify the existing procedure. I have a varray type of collection. The data that will be inputted via screen needs to be inserted in ALLOWANCE_HIST table. The program refers on the ...
strawberry kitori's user avatar
-1 votes
2 answers
78 views

String Iteration using Iterator interface in Lists

I was learning Collections in JAVA from a tutorial. In that during List topic I saw a line where we use a line to iterate the lists of type String in for loop using Iterator. Please refer to the piece ...
Pazhani_Kumar's user avatar
1 vote
1 answer
32 views

How can I modify multiple Mongoose collections simultaneously?

I have 3 Mongoose collection: Board, Thread and Reply. Each Reply belongs to 1 Thread (as an array's item in "replies" property) and each Thread belongs to 1 Board (as an array's item in &...
Arrow4986's user avatar
-2 votes
1 answer
55 views

Should I use a Map storing the id, or iterate over entries to find an object? [closed]

I'm wondering which of the following approaches I should use when finding an entry with an id from a collection? Using a map Map<String, MyObject> map = new HashMap<>(); public MyObject ...
Liam's user avatar
  • 35

1
2 3 4 5
480