Questions tagged [collections]

11365 questions
1

votes
1

answer
3.1k

Views

Error illegal start of simple expression

I am having this error : error: illegal start of simple expression def process_alcs(lines: List[String]) : List[(String, Double)] = for (line
Ruben Lejzerowicz
0

votes
2

answer
13

Views

CompactMap to filter objects that have nil properties

How do I filter out possible nil values in properties with a compactMap so I don't have to forecast a nil property to return the object. Currently I have let objects: [Object] = anotherObject.array.compactMap ({ return Object(property: $0.property!) }) What I would like is some guard staetment or op...
user1898829
1

votes
1

answer
389

Views

Behaviour of “containsAll” with duplicates

The official documentation (archive) of containsAll only says 'Returns true if this list contains all of the elements of the specified collection.'. However, I just tested this: List list1 = new ArrayList(); list1.add(1); list1.add(2); list1.add(1); List list2 = new ArrayList(); list2.add(2); list2....
Fabian Röling
1

votes
1

answer
680

Views

Does JPA return “null” or empty collection for a collection property that is empty in the DB?

If I have a JPA entity containing a collection field, such as public class Post { // [...] @OneToMany private List tags; the corresponding database schema will typically contain a separate table for storing the tags, where each record contains one tag and a foreign key reference to the 'Post' ta...
sleske
0

votes
2

answer
34

Views

Java Object Map when passed to function and used as a String Map does not implicitly convert object to String

Suppose a HashMap is defined as: void defineMap(){ Map options = new HashMap(); options.put('isValid','true'); options.put('isXYZ','false'); options.put('Size',6.0); int x = getFromMap(options); } Now, when this map is passed to a function and in the signature of the function, the Map is defined as...
Utkarsh Agrawal
1

votes
5

answer
299

Views

Sorting Strings that contains number in kotlin

I wanna sort some strings that contain numbers but after a sort, it becomes like this ['s1', 's10', 's11', ... ,'s2', 's21', 's22']. after i search i fount this question with same problem. but in my example, I have mutableList, and I must put all string in myModel.title for example into a mutable li...
Mehrdad Dolatkhah
1

votes
2

answer
378

Views

Laravel - convert array into eloquent collection

I need to use data from an API. I create a function: public function getItems() { $client = new \GuzzleHttp\Client(); $res = $client->get('https://app.example.com/api/getItems'); $vouchers = json_decode($res->getBody(), true); dd($vouchers); return view('api', compact('vouchers')); } and dd($voucher...
Aleks Per
1

votes
1

answer
33

Views

how to build scl, example are old and rpmlint contradict the documentation?

I read the official documentation, some examples on github and on atomicorp . But I am still confused! Should have to make 2 specs? One to build the tools and another one for a metapackage? If yes why atomicscorp's spec file seem to be a mix of spec and the meta-spec files ? Moreover with rpmlint 1....
bioinfornatics
1

votes
3

answer
37

Views

Laravel collections convert key value to key assoc array

I use this function: $assets->pluck('url'). It outputs: ['link','link1','link2'] How to convert it to: [{url: 'link'}, {url: 'link1'}, {url: 'link2'}]
Artshellorok
1

votes
3

answer
49

Views

Flatten a nested N-Level nested object in java

I have a java class class Example{ String field1; String field2; List subExamples; } In the above scenario, Example is having subExamples which is again a list of Examples. This nesting can be n-levels. What I want to achieve is to have a list of Examples, i.e to flatten the above object and col...
codeluv
1

votes
4

answer
37

Views

Check if a list of byte arrays contains a new byte array

I have a list of byte arrays and need to check if this list doesn't contain a new given byte array. If not, than I need to perform some action. Right now, I'm trying to do it like this: List listOFByteArrays = getListOfByteArrays(); byte[] newByteArray = getNewByteArray(); if (!listOfByteArrays.cont...
Coffemanz
1

votes
1

answer
174

Views

How to install GCC/G++ 8 on CentOS

I'm used to install packages on Debian/Ubuntu distributions, but now I need to install gcc and g++ version 8.*. There is only version 4.* in CentOS repositories. What's the correct way to install them manually?
Eenoku
2

votes
1

answer
21

Views

Is there any disadvantage of using thread safe collection classes like Hashtable in single thread environment?

I was asked by the interviewer about disadvantages of using thread safe class like Hashtable in single threaded environment? Are there any disadvantages? if not then why are there non thread safe class introduced later?
Gurpreet Singh
0

votes
3

answer
22

Views

Custom object as Map key

AS I have read that if custom objects need to be the key of map, hashcode and equals method need to override, but in my case its working without overriding it. Could someone please tell whats getting wrong ? Map map = new HashMap(); Student s1=new Student(1,'A'); Student s2=new Student(2,'B'); Stude...
Khan
1

votes
2

answer
531

Views

How to create a map of character and dynamic ArrayList in Java

I want to create a hashmap defined as HashMap. What I am trying to do is to read a set of strings which I am reading into a list. From this list I want to generate this hashmap. So if strings are something like this Andy,Aman,Rocky,Ravi,Nick etc. Map should be like A->[Andy,Aman] R->[Rocky,Ravi] N->...
1

votes
2

answer
474

Views

Split a row into two and dummy some columns

I need to split a row and create a new row by changing the date columns and make the amt columns to zero as in the below example: Input: +---+-----------------------+-----------------------+-----+ |KEY|START_DATE |END_DATE |Amt | +---+-----------------------+------------...
RaAm
1

votes
1

answer
328

Views

Get String value if present or null if not present using Java8 Stream

I have a json similar like as shown below. The requirement is to get the key value based on the id. ie. lets say If Id is A1 key value should return 2gAwIBAgIQKGZsKfAUzaJHVantyrwVdzANBgkqhkiG9w0BAQs. The key array will always conatins only one element. { 'keys': [ { 'id': 'A1', 'key': [ '2gAwIBAgIQ...
Alex Man
1

votes
1

answer
42

Views

Example of meaningful container elements

What's the usage of: https://docs.oracle.com/javase/7/docs/api/javax/xml/bind/annotation/XmlElementWrapper.html so that a 'collection of collections' can be created programatically in a standards acceptable fashion? IBM pdf with sample Example: The XML Institute Public Library IBM The XML Bible, 2nd...
Thufir
1

votes
1

answer
53

Views

sails.js remove all members from collection waterline

I want to remove all members that a collection has , but I do not want to pass every member ID to .member() method . waterline documentation explain a way to delete specific members like : await User.removeFromCollection(3, 'pets') .members([99,98]); I want to have sth like : await User.removeFromCo...
Jafar rezaei
1

votes
5

answer
61

Views

Show multiples of a given number within a range

How can I fix the following code in better way (alternative way to iterate range from first element to last element? My goal is to write kotlin code in most efficient and simplest way I am looking someone tell me instead of n/7 what should I write to get the same result of code val numList = 1..20...
Jack
1

votes
4

answer
43

Views

Scala: Better way to handle Future.Filter.exists without any specific conditions

Scala: I need to perform an action only if the previous future returned Some(x). what's a better way to do this than using below code def tryThis: Future[Option[T]] = {...} val filteredFuture = tryThis.filter(_.exists(_ => true)) def abc = filteredFuture.map( _ => {...})
Shamoel Ahmad
1

votes
1

answer
33

Views

How does Collections.unmodifiableCollection use equals method?

The unmodifiableCollection method (as well as thesynchronizedCollection and checkedCollectionmethods discussed later in this section) returns a collection whose equals method does not invoke the equals method of the underlying collection. Instead, it inherits the equals method of the Object class, w...
hometown
1

votes
3

answer
41

Views

Best way to find uncommon elements inside list [duplicate]

This question already has an answer here: returning difference between two lists in java 7 answers I am having lists of String type say list aLista and bListb first list might have at max 10 elements however bListb might have thousand or even more elements. Now i have to find all elements from aLis...
Sunil Goyal
1

votes
1

answer
31

Views

How the Java HashMap internal data structure changes during rehashing?

I am trying to write demo code to show rehashing is happening in Hashmap when the map size exceeds the load factor threshold. How can I prove rehashing is happening internally . Also I want to prove that eventhough the old entries are moved to new buckets during rehash , I can get the old elements...
JavaUser
0

votes
1

answer
20

Views

Refresh collectionView on viewdidload after retrieving UserDefaults

I have a collection view, and you can select the items in it and toggle them on and off by changing the background colour. The cells are toggled on/off thanks to a boolean I have in an arrow I made for all of the cells. I have saved the bool value but when I try to write them back into the array a...
YachtSamba
1

votes
2

answer
64

Views

Missing records from Mule ConsumerIterator

I am using a Mule component to process records from a Salesforce query. I wrote a Mule component to use the ConsumerIterator to aggregate the records in batches of 100. However, I don't get all the records. I included a simple count to count all the records and I am using an AtomicInteger to count t...
BreenDeen
1

votes
0

answer
24

Views

Symfony3- can´t access to collections data (get)

I have an object with several collection. I saved the data correctly and then, when I do 'object->getCollection()', I didn´t obtain the data. This are my entities: Persona: /** * @ORM\OneToMany(targetEntity='PersonaDomicilio',mappedBy='idPersona',cascade={'persist'},orphanRemoval=true) */ public $d...
1

votes
1

answer
73

Views

Mongo Command to filter a field based on its length

I have a mongo collection where Iam trying to filter all the records with a specific field of length =1 Iam trying to use below command and it gave below error ,can someone help here db.getCollection('accdetails').find({$where:'bankDetails.length = 1'}).sort({$natural:-1}) Below is the error Error:...
hammy
1

votes
0

answer
267

Views

Find latest record for based on multiple ID's using Meteor

I have a collection in mongodb which has the following format: { parentId: '12345akNu', createdAt: '2018-12-02', complete: false } I would like to find all most recent records for a set of parentId's which are not completed. I currently have this query to find all records, but I cannot figure out h...
Hans
1

votes
0

answer
242

Views

Work with associative arrays INDEXED BY VARCHAR2 based on different record types where not all elements may not be present

I am trying to work with with parsed data and place into structures to work with. I have found a Steve Feuersteins package that takes a string, and given seperator(s) will split it out into associative arrays and nested associative arrays. With some tweaking I have fit it to some additional things I...
programmerNOOB
1

votes
0

answer
108

Views

What is the Best C# Sortable Serialized List that can be used with DataContract?

As a part of a class, I have some Immutable POCO objects just to act as a Data Transfer Object for a configuration file. [DataMember] public IReadOnlyList Messages { get; } = new List() { new Warning(75, 'UserMessage1', 'LogMessage1'), new Warning(90, 'UserMessage2', 'LogMessage2'), new Error(100, '...
Ryan The Leach
1

votes
1

answer
32

Views

Collection of subclass objects that inherit (share) common superclass attributes

I'm trying to make a subclass to inherit attributes from its super, but at the same time, the super stores a collection objects of the subclass. Here's my try but I'm feeling this is not an efficient way to do it and probably there's other much better ways to implement it. class SuperCls: def __ini...
Bravhek
1

votes
0

answer
38

Views

How to clear an object of list after it gets processed once with iterator

I have one method which is writing is processing csv file as below: public void processFile(Mapper mapper) { List outputDataList = new ArrayList(); Iterator iter = this.addressLists.iterator(); while (iter.hasNext()) { List listOfAddress = iter.next(); for (AddressDto address : listOfAddress) { this...
user9193174
1

votes
1

answer
39

Views

How to get Laravel Collection from images using views

I have two tables images and views. images: user_id, name, path. views: user_id, viewable_id, viewabe_type, count. Image has Polmophic relation through viewable_id. How do i extract Laravel Collection of Images that have view count over 100?
Timothy Kimemia
1

votes
1

answer
103

Views

Indexing Faces with AWS Rekognition

I am new to AWS and am trying to use Rekognition to identify certain people in a crowd. I am currently trying to index the images of the separate individuals but have hit a snag when trying to create a collection. There seems to a data type compatibility issue when I try using Amazon.Rekognition.Mod...
willed42
1

votes
2

answer
98

Views

Stack sub Stack creation

How to create a stack within a stack? Like [[1 2 3][3 4 5][6 7 8]] So there are three substacks like [123], [456], [789] which sit within a main stack. How do I create it with stack build in function in Java?
Rima Sur
1

votes
0

answer
104

Views

Is there any way I can know creation date of an Index for MongoDB tables(collections)?

Is there any way I can know creation date of an Index for MongoDB tables(collections)? Recently, we saw some indexes which lead to some problem of space and performance and wonder if we can get the timestamp for create_date of the indexes. And I'm not sure if there is a way to do that in the most r...
Tony
1

votes
1

answer
28

Views

How to collapse a collection into one and sum specific keys

I have following collection: array:2 [▼ 0 => array:21 [▼ 'id' => 1 'referrer' => 'Kariane Muller DVM' 'path' => null 'tracking_code_id' => 30 'sales' => 2 'field_name' => 'ssn' 'income' => 4.0 'fsId' => '1b5e4434-da5a-342e-9b87-df9791b1bcc1' ] 2 => array:21 [▼ 'id' => 1 'referrer' => 'Kariane...
PrStandup
1

votes
1

answer
51

Views

How can I install SCL on Oracle Linux 6?

I would like to use the SCLs, but cannot find a way to install the release file. Is it possible to install SCL on Oracle Linux 6 and, if so, how?
Jörn Guy Süß
1

votes
0

answer
83

Views

How to sort UsageStats list accordingly TimeInForeground?

Here is the code that I am using to get List of UsageStats of every installed application. List usageStatsList = getUsageStatistics(UsageStatsManager.INTERVAL_DAILY); SortedMap mySortedMap = new TreeMap(); Collections.sort(usageStatsList, new SortListComparatorDesc()); Here is the SortListComparoto...
Ammy Kang

View additional questions