Most voted "list" questions
A list is an abstract type of data that represents a sequence of values, in which the same value can occur more than once. The main ways to implement a list is through an array (array, vector or one-dimensional matrix) or a chained list.
Learn more…1,022 questions
Sort by count of
-
49
votes1
answer13752
viewsDifference between Icollection, Ilist and List?
What’s the difference between ICollection, IList and List? When I should use each one specifically?
-
23
votes2
answers8037
viewsArraylist x List
What is the difference of declaring ArrayList and List for lists in Java? What are the advantages of using one or the other?
-
22
votes3
answers11209
viewsDifference between Any, Contains and Exists
What’s the difference between Any, Contains and Exists? What is the appropriate context for each of them? (Examples of use) What are the advantages and disadvantages?…
-
16
votes3
answers1114
viewsWorking with lists without using Array() in PHP
I know that in PHP for almost every kind of list, we work with Array(), but this would be the only way to work with PHP lists? Is there any other way to work with PHP object lists, like the…
-
16
votes2
answers11683
viewsWhat is the difference between Arrays.asList and List.of?
Studying Java 9, I saw a new method that works with collections: List.of, example: List<String> frutas = List.of("maça", "laranja"); I’ve used it before Arrays.asList, example:…
-
15
votes3
answers10708
viewsWhat is the main difference between a Tuple and a List?
What are the differences between a Tuple and a List in the Python? Example: >a = [1, 2, 3] # [1, 2, 3] >b = (1, 2, 3) # (1, 2, 3) The Tuple, grotesquely speaking, it is a constant that accepts…
-
15
votes3
answers7080
viewsIn a list, what is the difference between append and extend?
Num list in Python, there are the methods append and extend. What’s the difference between them and when to use each?
-
15
votes1
answer3299
viewsHow to compare two Arraylist and get the values shared by both?
I own two classes, they are: Filtrocity class: public class FiltroCidade { private int idCandidato; private List<String> cidades; public FiltroCidade(){ } public int getIdCandidato() { return…
-
14
votes2
answers288
views -
14
votes2
answers6664
viewsHow to create and manipulate lists in PHP?
In java it is possible to create and manipulate list of any type of data using the List<E>, See the example below: List<String> lista = new ArrayList<>(); lista.add("Stack");…
-
13
votes2
answers241
views -
12
votes2
answers1480
viewsHow to edit a list in C#?
I want to edit a record of a client in which I can already register, consult and remove. But I have no idea how to edit just a few items without others being lost. class Program { static…
-
12
votes4
answers17968
viewsRemove elements from a Python List
I have a problem with lists in Python. I have a list of 2 different variables with the same value, but if I remove an element from any of the lists, the list that was meant to be intact also has its…
-
12
votes3
answers3072
viewsHow to convert a string to List<int>
I have the following variable and would like to convert it to an integer list: string variavel = "1,2,3"; How to convert it to a list of integers?
-
12
votes3
answers13730
viewsWhat is the difference between simply-chained and double-chained list?
I’m having a hard time understanding the functioning and difference of a simply-chained list and a double-chained list, the two seem to have the same purpose and functioning. I know that both are…
-
12
votes3
answers844
viewsHow to initialize a list of empty lists?
Using Python 2.7.12 I need to create a list as follows: lista = [[],[],[],[],.........,[]] This list needs to have a very large number of lists within it (so the .....). I found around the following…
-
11
votes5
answers1656
viewsCreate objects within a list without for/foreach C#
private List<Compra> CriarCompras(int numComprasParaGerar) { List<Compra> lstCompras = new List<Compra>(); for (int i = 0; i < numComprasParaGerar; i++) lstCompras.Add(new…
-
11
votes2
answers23324
viewsCount the number of occurrences of a value in a list
I have a list with the following values: numeros = [5, 3, 1, 2, 3, 4, 5, 5, 5] In Python would have some function to count how many times some value repeats? For example: I want to know how many…
-
11
votes1
answer578
viewsWhy does iteration of a list with an anonymous object work with an array but not with List<Object>?
I tried the following iteration with C#: var objects = List<Object>{ new {Id = 2, Nome = "Wallace"}, new {Id = 4, Nome = "Cigano"} }; foreach (var user in objects) { Console.WriteLine ("Meu id…
-
11
votes1
answer269
viewsWhat sort algorithm does . NET use by default in a list?
I have a problem that I have to perform sorting in memory of a high number of items and I would like to know which algorithm that the . NET uses to sort when we call the method Sort() from a list,…
-
10
votes2
answers4980
viewsHow to determine the last element of a list in a foreach?
Given any list, how to know if the foreach is in the last element? There are some ways to do this, the one I see most is to save the last element and check if the current element is the same, but…
-
10
votes1
answer2100
viewsDifference between Std::list, Std::vector and Std:array
All are containers used for data guards in a sequential manner, but what are the main differences between them?
-
10
votes1
answer5341
viewsOrder By with List<>
It is possible to make a OrderBy in a List<> setting the value for comparison? Example: mRel.OrderBy(s => s.Status == EnumModel.StatusGeral.Novo).ToList() My Code:…
-
9
votes2
answers1683
viewsConvert a collection from Set to List type
I have a class that has an attribute of the type of Set, because I want repeated values to be ignored, however I need to return this in the form of a List to fill in a ListView, so what is the best…
-
9
votes1
answer510
viewsHow to make Jtable values the same as Arraylist<Pessoa>?
I have an example program that adds objects of my class type Pessoa in a JTable and also in a ArrayList<T>, this program has three basic functionalities which are as follows:: Add Alter Erase…
-
9
votes2
answers7582
viewsHow to capture the last element of a list in Python?
In PHP, to take the last element of a array I can do it like this: $array = array(1, 2, 3); echo end($array); // 3; And in Python? How could I do that with this list: arr = [1, 2, 3]…
-
9
votes1
answer1028
viewsWhat is the maximum number of items I can put inside a List<T> in C#?
I have several questions of performance in my application. What is the maximum number of items I can within my List<T> and what is "acceptable" within good practice.
-
9
votes2
answers785
viewsArraylist versus List
Why in C# we should prefer to use the List instead of ArrayList?
-
8
votes2
answers385
viewsIn which scenario is it recommended to use Keyedcollection instead of a Dictionary?
I didn’t know about the existence of KeyedCollection until you see this reply gypsy. I wondered how and when to use a KeyedCollection, since there is the Dictionary which apparently has the same…
-
8
votes8
answers2805
viewsHow to know which is the last element on a list?
I am doing a dynamic sql query, in which I use lists, my problem is, how to know which last element of this list Follow the code made so far: List<string> campos = new List<string>();…
-
8
votes2
answers15912
viewsHow do I join a list in Python?
When I want to unite a array in PHP, I use the function array_merge Thus: $a = [1, 2, 3]; $b = [4, 5, 6]; array_merge($a, $b); Upshot: [1, 2, 3, 4, 5, 6] And how could I do that in Python in a list…
-
8
votes2
answers16188
viewsHow to compare two lists in Python?
I have two lists whose contents refer to a arquivo1.txt and the other one arquivo2.txt, there are differences in the contents of the files and wish to search only the data that is in file2.txt and…
-
8
votes3
answers3818
viewsUpdate an item from a generic list to a specific item
How do I update a specific element of a generic list by locating by ID and passing an updated object in its place, updating the name and email? class Program { static void Main(string[] args) {…
-
8
votes3
answers1885
viewsLongest word in a sentence in the list - Python
The code in Python need to find the largest word in the typed phrase that will be stored in the list, being displayed later. The only thing I know about the resolution of this code is using the…
-
8
votes2
answers114
viewsWhat is the function of Asreadonly() in C#?
I’m studying List in C#, I searched on the internet but still did not understand how it works. List<string> list = new List<string>(); list.Add("Maria"); list.Add("Lucas");…
-
8
votes3
answers190
viewsHow to get the index of the first positive element in a list?
I am looking for a solution to a very simple problem. I need to get the first element of a list greater than or equal to zero. I was able to do this with the following function: def…
-
7
votes2
answers3113
viewsHow to pick a random string from a list of strings?
Code: nomes = new string[5]; nomes[0] = "José"; nomes[1] = "Carlos"; nomes[2] = "João"; nomes[3] = "Miriam"; nomes[4] = "Estela"; I put an array, but it doesn’t have to be with an array, it can be…
-
7
votes2
answers212
viewsWhy Arraylist instead of Stack in the implementation of the Memento standard?
As you all know, the Memento pattern is the pattern that saves different states of objects and then retrieves them. The intention is not to retrieve the "last" to enter and then remove it? This is a…
-
7
votes1
answer1357
viewsProblem placing multiple data from a list in a report
Good morning guys, this is a somewhat complicated question to explain, so I will do my best to make the question clear. I have a list <UnimedLote>. In this list I have several data, among…
-
7
votes3
answers108
viewsHow can I restructure information contained in a list object into two columns?
Considering a list x composed of nvectors. To illustrate the problem I thought it had 3 elements, as follows: >x $`2751006` [1] 106.2 75.4 65.4 87.4 76.8 196.4 74.2 $`2751007` [1] 73.9 110.1…
-
7
votes3
answers13058
viewsHow to do a range with letters of the alphabet in python?
In PHP, when we want to make a array alphabet letters, we can use the function range. Example in PHP: $letras = range('a', 'z'); Upshot: Array ( [0] => a [1] => b [2] => c [3] => d [4]…
-
7
votes2
answers5391
viewsHow to update an item from a generic list?
I am trying to change the name and email of a particular item in the list below, but I couldn’t find another way to remove the item from the list and add it again updated. There is another way to…
-
7
votes3
answers14487
viewsDivide a list into n sublists
I have the following list: l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] What I need is to divide this list into n sublists, in this case it is not possible to do it manually because the n…
-
7
votes3
answers1360
viewsFaster way to access properties in a C#list
I have a project that works with a large volume of data, and I need to optimize it to bring results of some calculations in a considerably small time. I know that I have several aspects to take into…
-
7
votes4
answers16556
viewsGenerate random numbers in Python without repeating
I have the following situation: I have a vector with 4 indexes. In each index a random value is generated from 0 to 100. I have a code that does this perfectly, but sometimes the numbers repeat.…
-
7
votes6
answers49406
viewshow to search for an element in a list that is inside another list?
I have the following list composed of lists. [['julian', '0', '5'], ['ana', '10', '4']] and I need to use a function that tells me the position of any element within that list, I tried to use:…
-
7
votes1
answer891
viewsIs it possible to unstructure an array in PHP equal to or similar to the Python list?
In Python we can unstructure a list like this: lista = [ "Maça", "Pera" ] maca, pera = lista print(maca, pera) the exit will be: Maça Pera I know that in PHP it is possible to get the result using…
-
7
votes2
answers161
viewsHelp Using List Comprehension/Dictionary
Hello, I have the following module (did not want to put all the code here) in Python >= 3.6. It is already functional in the current state, although it does not handle all possible errors. But I…
-
7
votes2
answers195
viewsQuestion about entering items in a list with indexes inside Python brackets
You can insert items into a list using methods such as, append(), extend(), or insert(). But it is also possible to insert through indexes in square brackets, normally used to replace items and not…
-
7
votes2
answers141
viewsHow to Split by Capital Letters and Numbers at the same time?
How can I separate a string by letters and numbers at the same time? For example if I have strings: composto1 = 'H2SO4' composto2 = 'CaCO2' composto3 = 'C20H17' I’ve tried to do: import re…