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
4
votes
2 answers

How to check if file object is random access

I have a function that accepts an arbitrary file handle and either loads all the data or allows the data to be loaded lazily if the object supports random access. class DataLoader: def __init__(self, file): self.file = file …
Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
4
votes
3 answers

search a line in preprocessed big text file

I have a data file which contains 100,000+ lines, each line just contains two fields, key and value split by comma, and all the keys are unique. I want to query value by key from this file. Loading it to a map is out of question as that consumes too…
jfly
  • 7,715
  • 3
  • 35
  • 65
4
votes
2 answers

Indexing / random access to 7zip .7z archives

Tools exist to provide random access to gzip and bzip2 archives: gzip zran.c from the ghostscript source code bzip2 seek-bzip by James Taylor I'm looking for any similar solution for 7zip (The goal is to utilize the sometimes gigantic Wikipedia…
hippietrail
  • 15,848
  • 18
  • 99
  • 158
4
votes
1 answer

Does RandomAccessIterator imply that the data is continuous in memory?

The other iterator types surely don't have the implication that they point to continuous data, but I'm wondering if I can treat RandomAccessIterators as if they point to a buffer of continuous data – i.e. they could be converted to pointers to data.…
Felix Dombek
  • 13,664
  • 17
  • 79
  • 131
4
votes
2 answers

Fast random access to a collection

I'm consuming a stream of semi-random tokens. For each token, I'm maintaining a lot of data (including some sub-collections). The number of unique tokens is unbounded but in practice tends to be on the order of 100,000-300,000. I started with a list…
Basic
  • 26,321
  • 24
  • 115
  • 201
4
votes
2 answers

Random access on .NET lists is slow, but what if I always reference the first element?

I know that in general, .NET Lists are not good for random access. I've always been told that an array would be best for that. I have a program that needs to continually (like more than a billion times) access the first element of a .NET list, and I…
user3685285
  • 6,066
  • 13
  • 54
  • 95
4
votes
1 answer

Random access queue data structure

I'm looking for a data structure to implement a random access queue ("straight" queue, not priority). That is, standard queue operations (push to back, delete from front, size/isEmpty), but with the wrinkle that I want to be able to do array-like…
TLW
  • 1,373
  • 9
  • 22
4
votes
6 answers

Read random lines off a text file in go

I am using encoding/csv to read and parse a very large .csv file. I need to randomly select lines and pass them through some test. My current solution is to read the whole file like reader := csv.NewReader(file) lines, err :=…
Ali
  • 18,665
  • 21
  • 103
  • 138
4
votes
1 answer

Why does RandomAccessFile use int as offset

I am writing some data access test implementation and I need random access to file content. Here's the code: RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rwd"); final byte b[] =…
Illarion Kovalchuk
  • 5,774
  • 8
  • 42
  • 54
4
votes
2 answers

random access file in java

I have the following fields: Inventory control (16 byte record) Product ID code (int – 4 bytes) Quantity in stock (int – 4 bytes) Price (double – 8 bytes) How do I create a fixed length random access file using the above lengths? I tried some…
user21968
  • 1,145
  • 6
  • 13
  • 19
4
votes
8 answers

c# Fastest way to randomly index into an array

I have an array of double values "vals", I need to randomly index into this array and get a value. GenRandomNumber() returns a number between 0 and 1 but never 0 or 1. I am using Convert.ToInt32 to basically get everything to the left of my decimal…
m3ntat
  • 3,635
  • 11
  • 38
  • 50
3
votes
1 answer

Converting Quick BASIC to VB.Net - Random Access Files

I'm trying to convert an old Quick BASIC program to VB.Net. There doesn't appear to be any direct replacement for the old file statements. Building a database seems like overkill for my simple needs. How can I do the following in VB.Net? OPEN…
3
votes
1 answer

Java: obtain the filename from a opened RandomAccessFile instance

How can I obtain the filename from a opened RandomAccessFile instance? I can find only the following methods related to the file itself: getFD() : which returns a FileDescriptor object getChannel() : which returns a FileChannel object I would like…
alexroat
  • 1,687
  • 3
  • 23
  • 34
3
votes
1 answer

Cant find the newline character in a file (java)

I am trying to get the last line of a file, but my output shows that it never finds it. I also tried looking for "[" which all the lines start with, but unless the jumps were perfect the program will not skip "[". I tried looking for "\r\n",…
Juan
  • 521
  • 1
  • 11
  • 28
3
votes
1 answer

Random access in a 7z file

I have a 100 GB text file in a 7z archive. I can find a pattern 'hello' in it by reading it by 1 MB block (7z outputs the data to stdout): Popen("7z e -so archive.7z big100gb_file.txt", stdout=PIPE) while True: block =…
Basj
  • 41,386
  • 99
  • 383
  • 673