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
84
votes
5 answers

SQLite - ORDER BY RAND()

In MySQL I can use the RAND() function, is there any alternative in SQLite 3?
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
72
votes
10 answers

Compression formats with good support for random access within archives?

This is similar to a previous question, but the answers there don't satisfy my needs and my question is slightly different: I currently use gzip compression for some very large files which contain sorted data. When the files are not compressed,…
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
50
votes
4 answers

STL deque accessing by index is O(1)?

I've read that accessing elements by position index can be done in constant time in a STL deque. As far as I know, elements in a deque may be stored in several non-contiguous locations, eliminating safe access through pointer arithmetic. For…
jasonline
  • 8,646
  • 19
  • 59
  • 80
31
votes
5 answers

What is the best compression algorithm that allows random reads/writes in a file?

What is the best compression algorithm that allows random reads/writes in a file? I know that any adaptive compression algorithms would be out of the question. And I know huffman encoding would be out of the question. Does anyone have a better…
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
29
votes
4 answers

How does random access memory work? Why is it constant-time random-access?

Or in other words, why does accessing an arbitrary element in an array take constant time (instead of O(n) or some other time)? I googled my heart out looking for an answer to this and did not find a very good one so I'm hoping one of you can share…
Kacy
  • 3,330
  • 4
  • 29
  • 57
23
votes
6 answers

Buffered RandomAccessFile java

RandomAccessFile is quite slow for random access to a file. You often read about implementing a buffered layer over it, but code doing this isn't possible to find online. So my question is: would you guys who know any opensource implementation of…
marcorossi
  • 1,941
  • 2
  • 21
  • 34
23
votes
4 answers

Why does Collections.shuffle() fail for my array?

Why does my code not work? package generatingInitialPopulation; import java.util.Arrays; import java.util.Collections; public class TestShuffle { public static void main(String[] args) { int[] arr = new int[10]; for (int i =…
Dmitry
  • 3,028
  • 6
  • 44
  • 66
21
votes
7 answers

Python Random Access File

Is there a Python file type for accessing random lines without traversing the whole file? I need to search within a large file, reading the whole thing into memory wouldn't be possible. Any types or methods would be appreciated.
Mantas Vidutis
  • 16,376
  • 20
  • 76
  • 92
21
votes
10 answers

.NET C# - Random access in text files - no easy way?

I've got a text file that contains several 'records' inside of it. Each record contains a name and a collection of numbers as data. I'm trying to build a class that will read through the file, present only the names of all the records, and then…
tabull
18
votes
3 answers

random.choice() returns same value at the same second, how does one avoid it?

I have been looking at similar questions regarding how to generate random numbers in python. Example: Similar Question - but i do not have the problem that the randomfunction returns same values every time. My random generator works fine, the…
Axel Ekeberg
  • 370
  • 1
  • 4
  • 15
17
votes
5 answers

C++ iterate vector randomly

I'm working on a multithreaded program where all threads share some vector (read-only). The goal of each thread is to walk the entire vector. Nonetheless, all threads must visit this vector in a different way. Since the vector is const and shared…
Esus
  • 173
  • 9
17
votes
8 answers

is there a such thing as a randomly accessible pseudo-random number generator? (preferably open-source)

first off, is there a such thing as a random access random number generator, where you could not only sequentially generate random numbers as we're all used to, assuming rand100() always generates a value from 0-100: for (int i=0;i<5;i++) print…
16
votes
2 answers

Does FileInputStream.skip() do a seek?

I want to copy the last 10MB of a possibly large file into another file. Ideally I would use FileInputStream, skip() and then read(). However I'm unsure if the performance of skip() will be bad. Is skip() typically implemented using a file seek…
Mike Q
  • 22,839
  • 20
  • 87
  • 129
13
votes
10 answers

How to insert characters to a file using C#

I have a huge file, where I have to insert certain characters at a specific location. What is the easiest way to do that in C# without rewriting the whole file again.
Gulzar Nazim
  • 51,744
  • 26
  • 128
  • 170
13
votes
4 answers

Random access gzip stream

I'd like to be able to do random access into a gzipped file. I can afford to do some preprocessing on it (say, build some kind of index), provided that the result of the preprocessing is much smaller than the file itself. Any advice? My thoughts…
jkff
  • 17,623
  • 5
  • 53
  • 85
1
2 3
22 23