Questions tagged [random-access]

Random access is the possibility of accessing any given record in a collection in the same time in contrast to sequential access in which distant records take longer to access than nearby records. An array is an example of a random-access data structure which can be contrasted to a list which requires sequential access.

Random access is the possibility of accessing any given record in a collection in the same time in contrast to sequential access in which distant records take longer to access than nearby records. An array is an example of a random-access data structure which can be contrasted to a list which requires sequential access.

See also

345 questions
13
votes
2 answers

Why ArrayList performance differs if it is referenced as List?

It was mentioned in the kjellkod's article that if we pass ArrayList in the method which receives List as an argument, then we lose in performance because ArrayList implements additional RandomAccess interface. Example from article: // SLOWER: as…
Roman Petrenko
  • 1,052
  • 1
  • 9
  • 21
12
votes
2 answers

How are random access iterators for non-contiguous containers (such as std::deque) implemented?

I understand how random access iterators work for contiguous containers like std::vector: the iterator simply maintains a pointer to the current element and any additions/subtractions are applied to the pointer. However, I'm baffled as to how…
chbaker0
  • 1,758
  • 2
  • 13
  • 27
11
votes
2 answers

Closing a RandomAccessFile sometimes takes exactly 45 seconds

In my program, closing a java.util.RandomAccessFile sometimes takes exactly 45 seconds (well, almost exactly: between 44.998 and 45.003 seconds). The program creates and closes lots of small files. Usually closing the file is very quick (between 0…
Thomas Mueller
  • 48,905
  • 14
  • 116
  • 132
10
votes
3 answers

Very fast sampling from a set with fixed number of elements in python

I need to sample uniformly at random a number from a set with fixed size, do some calculation, and put the new number back into the set. (The number samples needed is very large) I've tried to store the numbers in a list and use random.choice() to…
user972432
  • 317
  • 2
  • 8
10
votes
1 answer

Seeking in AES-CTR-encrypted input

As AES in CTR mode is great for random access, lets say I have a data source created with a CipherOutputStream in AES-CTR mode. The library underneath—which is not mine—uses a RandomAccessFile that allows to seek to a specific byte offset in the…
akaIDIOT
  • 9,171
  • 3
  • 27
  • 30
9
votes
3 answers

File Streaming in Java

I'm currently developing 3D graphics application using JOGL (Java OpenGL binding). In brief, I have a huge landscape binary file. Due to its size, I have to stream terrain chunks in the run-time. Therefore, we explicitly see the random access…
Alexander Shukaev
  • 16,674
  • 8
  • 70
  • 85
9
votes
1 answer

How do GPUs handle random access?

I read some tutorials on how to implement a raytracer in opengl 4.3 compute shaders, and it made me think about something that had been bugging me for a while. How exactly do GPUs handle the massive amount of random access reads necessary for…
Errata - C
  • 190
  • 2
  • 9
9
votes
1 answer

How are PDF files able to be partially displayed while downloading?

According to the PDF 1.7 specification, page 90, Sec 3.4: The preceding sections describe the syntax of individual objects. This section describes how objects are organized in a PDF file for efficient random access and incremental update. A…
myermian
  • 31,823
  • 24
  • 123
  • 215
9
votes
2 answers

Which data structure supports efficient deleting and random access?

I am looking for a data structure in which I can efficiently remove items and also supports random access. I also need efficient insertion but as the ordering of elements is not important, I thought I can preallocate memory for maximum number of…
MikeL
  • 2,369
  • 2
  • 24
  • 38
9
votes
3 answers

Efficiently choosing a random line from a text file with uniform probability in C?

This is essentially a more constrained version of this question. Suppose we have a very large text file, containing a large number of lines. We need to choose a line at random from the file, with uniform probability, but there are…
John Doucette
  • 4,370
  • 5
  • 37
  • 61
8
votes
1 answer

Random access file FileLock: java.io vs. java.nio

I've noticed that java.io and java.nio implementations of random access files differ slightly with respect to how FileLocks are handled. It appears as though (on Windows) java.io gives you a mandatory file lock and java.nio gives you an advisory…
predi
  • 5,528
  • 32
  • 60
8
votes
6 answers

Random string in Django template

Is there any way to have a random string in a Django template? I would like to have multiple strings displaying randomly like: {% here generate random number rnd ?%} {% if rnd == 1 %} {% trans "hello my name is john" %} {% endif %} {% if rnd ==…
kollo
  • 1,285
  • 3
  • 20
  • 33
7
votes
4 answers

Reaching a specific line in a file using RandomAccessFile

Is it possible to position cursor to the start of a specific line in a file through RandomAccessFile? For e.g. I want to change String starting at char 10 till 20 in line 111 in a file. The file has fixed length records. Is it possible to directly…
Vicky
  • 16,679
  • 54
  • 139
  • 232
7
votes
2 answers

efficient GPU random memory access with OpenGL

What is the best pattern to get a GPU efficiently calculate 'anti-functional' routines, that usually depend on positioned memory writes instead of reads? Eg. like calculating a histogram, sorting, dividing a number by percentages, merging data of…
dronus
  • 10,774
  • 8
  • 54
  • 80
7
votes
2 answers

compilation error: request for member in something not a structure or union

Edit: The code below has been modified to work as the problem has been solved. Specifically, (*hardwareList.next_item)->next was originally written without brackets (e.g. as *hardwareList.next_item->next) and the compiler didn't understand it. I'm…
Adam M-W
  • 3,509
  • 9
  • 49
  • 69
1
2
3
22 23