Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [list]

The tag has no usage guidance.

0
votes
2answers
121 views

Creating a list of functions in java [closed]

I have a list of functions which need to be tested against a list of inputs to measure their relative performance. I have already create a test function like below: public static String testFunction(...
0
votes
2answers
100 views

What is list of arrays in python?

I read in the Python time complexity page: A deque (double-ended queue) is represented internally as a doubly linked list. (Well, a list of arrays rather than objects, for greater efficiency.) Both ...
0
votes
0answers
58 views

Finding appropriate positions for coordinates added to a coordinate-list

I am looking for the most efficient way to find the appropriate position of a geographical coordinate in a list of other (geographical) coordinates forming a route. That may sound a little cryptical, ...
1
vote
1answer
331 views

How are list elements accessed in python internally?

Like if I want to access an array element in C it's implemented like this: For example: If a = {0, 1, 2, 3} is an array if I want to access index number 2 I will write a[2] and the formula that is ...
1
vote
2answers
165 views

Are there any use cases for List when Deques and Arrays are available?

I've been thinking about this over the past few weeks, and I've come up with no good arguments. My perspective is from Java, but if anyone has any language-specific cases outside of this language, I'...
1
vote
0answers
50 views

How should I store a frequently accessed array with an unknown number of elements in mongodb?

I have a simple "Index" object defined as follows: { "position": 4, "value": 345 } And I'm trying to figure out the best way to store this object in a mongo database, assuming that: The "...
4
votes
1answer
2k views

Which C# type should one prefer for defining lists in DTOs?

I was wondering if there is a recommended approach to defining a property of a plain object that is used for data transfer, for example via a REST-API which is a list of other objects. Which C# type ...
-5
votes
1answer
1k views

How to create a method that takes array list as argument?

To create a method that takes an array as an argument, you would do this: public static void printAges(int[] age) { // prints ages to screen for (int x = 0; x < age.length; x++) { ...
-1
votes
2answers
98 views

Are there good habits that can mitigate conflation of list structure types in practice?

I'll start by explaining what I mean in particular. Background In Javascript, arrays do it all (more or less a Lispy trait). Not only can you initialize, push, and pop, but you can also iterate, ...
30
votes
6answers
12k views

Why does Python only make a copy of the individual element when iterating a list?

I just realized that in Python, if one writes for i in a: i += 1 The elements of the original list a will actually not be affect at all, since the variable i turns out to just be a copy of the ...
0
votes
3answers
1k views

Querying data with SQL vs. C# [duplicate]

I'm trying to decide who is right in the following argument: How to effectively process data in MSSQL? Which one is faster? Opinion 1: Data requests (this is especially true for complex ones) should ...
1
vote
5answers
5k views

Find duplicate in a list of a list of integers

What is the best way to find the duplicates in a list of a list of integers (no matter what position thay are in)? I don't necessary need code just the best way to go about this problem. eg: List&...
-2
votes
2answers
422 views

Is 'List' a leaky abstraction?

Abstraction - Creates barrier between representation & usage of List ADT Encapsulation - Ensures maintaining in-variants of List ADT. An invariant is a fact about a data structure that is ...
48
votes
6answers
6k views

What would be the disadvantage to defining a class as a subclass of a list of itself?

In a recent project of mine, I defined a class with the following header: public class Node extends ArrayList<Node> { ... } However, after discussing with my CS professor, he stated that ...
2
votes
1answer
501 views

Best way to store ListView Data(ListView.Items) into file

I just came across this question telling how to store ListView Data(basically ListView.Items) into a text file but it got me thinking that, is it the best way to do it? In terms of efficiency, ...
1
vote
4answers
248 views

Chunking an array into letter groups that are generally equal length

Given a list of items, I want to break it up into four groups with as equal length as possible. The items need to stay grouped by the first letter in each item as well. 26 letters / 4 groups would ...
3
votes
2answers
144 views

Implementing a key-sensitive monad bind for key-value Map

Based on the List monad I set out to define Monad instances for the Map type from Data.Map, to perform chained unions and folds on Maps like lists, but with the efficient sorting and merging of Maps: ...
4
votes
6answers
2k views

Conditionally initializing a string list

I am writing a program that needs to be able to process data from a number of different sources. The sources output data in a variety of formats. So, depending on which source is being used, I need to ...
0
votes
1answer
68 views

Search list items from other list, better way?

Today I have to search items of list from another list individually. I am just thinking about some better approach. Below is scenario described. Lets say I have two arrays, arr1 having 100 elements (...
0
votes
2answers
222 views

Check if list has a list of values

I have been trying to figure out an efficient algorithm that can check if a list of values contains a list of values. Both lists are sorted in ascending order. For example: Check if var ...
2
votes
3answers
560 views

Logic Programming(Unification) vs List Comprehensions (in Functional Programming)

I found this answer on StackOverflow very clear to explain the difference beween the Logic Programming paradigm and the Functional Programming paradigm: The thing that makes logical append ...
1
vote
2answers
3k views

Is python list comprehension using multi-threading or parallelized in any way by default?

When I write... l2 = [my_computation(x) for x in l] ..., I wonder if python is applying my_computation to every x using all cores of my CPU. If not, why ? Is there a simple way to make python ...
1
vote
4answers
86 views

Obtaining lists from an array

Let's say my array contains integers. I'd like to create lists, so that every list contains indexes where a particular value occured in the array. For instance, if the array was 5,0,3,5,2,5,3, we ...
2
votes
3answers
4k views

Is returning a json object instead an array via REST good or bad style?

I am working on my API and would like to return some stats. Those are stored and collected in code, and I can choose my way to return those. My first approach was using hash, so my data looks like: {...
0
votes
1answer
385 views

How to save tuplas values, to later search on it

Scenario I have some values of the type : (Name - Email) From this couples of data, I have to set a ArrayList of "Name" values,something like: |Name1|Name2| --- |NameN| to set a Spinner. (Ordered ...
3
votes
3answers
5k views

Why don't empty iterables in python raise Exceptions when you try to iterate over them [duplicate]

I find this behaviour in Python quite peculiar and I believe it can lead to many bugs especially if you have a function/method that takes in a list and returns another list after carrying out some ...
1
vote
2answers
138 views

Load to list in one loop and then process list in another or do it all at once

I have a dataset full of rows that I must initialize into myclass and then process. I am currently looping through each row in the dataset, initializing a new instance of myclass, then adding that ...
0
votes
1answer
1k views

Efficient way in comparing two lists

I have created two lists of objects: One is records from an xml and the other is records from the database. The rule is check if the record from an xml exist in the database then exclude. I have ...
3
votes
1answer
2k views

JavaScript functional conversion from flat list to tree

I've been going through the RxJS tutorials http://reactivex.io/learnrx/. Almost all of the exercises involve moving from a hierarchical structure to a flat structure so I thought I'd try to do the ...
3
votes
3answers
185 views

Is it odd if Nodes in a LinkedList held references to the List object?

Its like, I want to call .moveToBefore(Node) on a Node object and have the node relocate to before the node passed in. The problem arises if the node passed in is the head node. The List object will ...
0
votes
3answers
4k views

Functional programming: Compare all items in an array

In functional programming, how do I do an equality comparison of all items in an array? I have an array of items that I want to compare, for example for equality. Is it possible to use a fold (also ...
35
votes
5answers
81k views

What's the use of .Any() in a C# List<>?

I've been discussing this with colleagues, and we couldn't figure out what the use is of .Any for any given List<>, in C#. You can check the validity of an element in the array like the ...
4
votes
1answer
150 views

Performance of list concatenation followed by scanning

Consider the following code snippet: -- list_1 = [1, 2, 3] -- list_2 = [4, 5, 6] final_list = list_1 ++ list_2 result = map (+1) final_list Is the time spent by it proportional just to the length ...
4
votes
2answers
7k views

Is there a key/key lookup table type provided in .NET?

It seems like a pretty straightforward thing to add, but I just want to be sure .NET doesn't already provide one and save me from adding unnecessary code: I need a lookup table (like a Dictionary) ...
4
votes
1answer
8k views

When should I use a generator and when a list in Python? [duplicate]

I often find it cleaner to write a generator than to return a list. For example, I prefer def my_func_gen(foo): for i in foo: # Do some stuff that's too complicated for a list or ...
4
votes
2answers
429 views

Is this data model a list or tree?

Using python syntax with below environment diagram, teacher taught us that there are 11 trees(orange boundary) in this diagram, including leaf. It has been taught here, lists are represented as a ...
3
votes
1answer
1k views

Why is iterating through List<T> more expensive than iterating through Array in .NET?

According to the answers in this post, List<T> is backed by an Array. According to this article, list iteration is considerably slower than array iteration. If Lists are arrays 'under the hood',...
3
votes
1answer
215 views

What data type is this?

I have a list of items I am adding to, however this special list will delete anything past a given capacity. Note the order is maintained. For the life of me, I can't think of the name of such a ...
-1
votes
2answers
2k views

'Tuple' vs 'List' operations in python

Only two operations are allowed on tuple, as shown below. Operations like insert / delete at an index is not allowed. I learnt that tuple is an immutable data model. list allows insert and delete ...
-2
votes
3answers
541 views

Is LinkedList an Abstract Data Structure? [duplicate]

This quote is from the book HeadFirst C: A linked list is an example of an abstract data structure. It’s called an abstract data structure because a linked list is general: it can be used to ...
5
votes
3answers
653 views

Is storing data directly in a list node better than storing a pointer to data?

Suppose we have two different doubly-linked list structures: One has content of the node embedded directly in the node: struct Content { // some stuff }; struct Node { struct Node *next; ...
3
votes
1answer
176 views

Why use atomic vectors or matrices in R at all?

In reading Hadley Wickham's Advanced R I learned about the difference between atomic vectors and lists; and matrices/arrays and dataframes. This is something I hadn't really appreciated before, and ...
4
votes
1answer
2k views

Maintain ordered collection by updating as few `order` fields as possible

I'm working on integrating a reorderable lists UI widget with a Meteor.js (MongoDB, in effect) collection: { order: ???, // what type to use here? property1: ..., ... propertyN: ... } Each ...
5
votes
2answers
5k views

Why does java collections not supply a function for the index of max value?

I have been using Collections.max(list) for many projects, but I occasionally want to find the index of that maximum element. I feel silly writing a function to do this for myself in every program I ...
2
votes
2answers
3k views

Why a hashtable? Why not just a non-hashed associative array?

I've been learning about using a hashtable to efficiently check for items in a list without looping through the whole thing, but there's one thing that I don't get: Why hashed keys? It seems like: ...
0
votes
1answer
235 views

Why is first column of list called 0th in so many languages? [duplicate]

If you want first element of list or array you reference it as 0 in many languages (like C or Clojure). Is there are some really good reasons why the programming languages was design this way? In ...
0
votes
1answer
504 views

Design Pattern : Static Array/List in Class Object

I'm a CS alumni, but we didn't learn much by the way of OOP, or Design Patterns. I've heard the phrase C with iostreams and thought it fitting. Anyway that's besides the point. I am just curious about ...
4
votes
1answer
431 views

Tail-recursive implementation of take-while

I am trying to write a tail-recursive implementation of the function take-while in Scheme (but this exercise can be done in another language as well). My first attempt was (define (take-while p xs) ...
1
vote
1answer
121 views

Using a list of tuples vs a list of custom objects

I have a situation where I have several text documents and I want to create a list that contains the words in those documents. But I also need to record several properties of each word. These ...
0
votes
1answer
100 views

Is there a design pattern for updating lists?

I want to modify one list (actually info stored in a database). A person doesn't have access to update every part of the list, but can update and delete parts they do have access to and add whatever ...