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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
20 views

Have Sysbench memory rndrd/rndwr tests eliminate the affect of cache?

In short, my question is: Should Sysbench eliminate the effect of cache when measuring the memory read/write performance, similar to how the effect of memory is eliminated when measuring the disk ...
ada liu's user avatar
0 votes
2 answers
64 views

Exhaust list of elements randomly without sorting them randomly first

If I have a list of 10K elements, and I want to randomly iterate through all of them, is there an algorithm that lets me access each element randomly, without just sorting them randomly first? In ...
Alexander Mills's user avatar
-1 votes
1 answer
248 views

How to make 'Published<[String]>.Publisher' conform to 'RandomAccessCollection'

I am trying to make a view that updates based on if the user toggles the favorite button or not. I want the entire view to reconstruct in order to display an array of values whenever that array of ...
Linda Xue's user avatar
1 vote
2 answers
352 views

How to do random access of specific blocks in an .xz file?

My goal is to be able to reduce time needed to look at specific sections from the middle of very large log files compressed to .xz format. If the .xz files are for example 6GB compressed and 60GB ...
abcd efg's user avatar
3 votes
1 answer
453 views

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", ...
Basj's user avatar
  • 41.1k
1 vote
1 answer
41 views

Is creation of an instance of type ArraySlice<Character> via this approach an O(1) time operation?

Re: Swift 5 let str = "my string" let slice: ArraySlice<Character> = ArraySlice(str) Is the ArraySlice created in O(1) time? I'm curious because complexities pertaining to extended ...
xct789's user avatar
  • 46
0 votes
2 answers
103 views

Getting a random element from a Collection

in java I would like to be able to maintain my Collection of fishes sorted by species at all time (hence the use of a HashMap) while being able to pick a random element from all species except one ...
Guillaume Valhall'art Roussel's user avatar
1 vote
1 answer
621 views

AES 128 CTR random access decryption with cryptography.hazmat in Python

In theory AES encryption in CTR mode allows for decrypting at any block index (that is you don't have to decrypt the whole encrypted data from the begining if you want to decrypt only from a certain ...
user2960174's user avatar
1 vote
1 answer
95 views

Best way to randomly access and modify sequential data in Perl

The input to my Perl program is a text file that contains one 'item' per line. For example, a file with below contents: item1 abc yyy anything blabla whatever item2 efg dod whatever blabla mmm item3 ...
hw_engineer_trying_to_write_sw's user avatar
1 vote
0 answers
79 views

RandomAccessFile class - trouble with readiing/writing first item of LinkedHashMap

Here is the main code: import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { RandomAccessFile raf = new RandomAccessFile(&...
MrJ_'s user avatar
  • 55
1 vote
1 answer
157 views

How to design an efficient algorithm to support random access in LZ77 compressed sequences?

I'm working on a project in text compression and I need to design an efficient algorithm in a LZ77 compressed sequences. Specially, Given a LZ77 compressed sequence and an index i, we can recover a ...
Tina's user avatar
  • 21
1 vote
1 answer
135 views

What's the underlying reason that object storage can not support edit/update/append file?

I know object is immutable and its content could not be edited, but I'm curious about why. Is it because S3 use RESTful API and PUT doesn't support partial write? But why not just transfer the data of ...
tianhao's user avatar
  • 11
0 votes
0 answers
175 views

c++: variadic nested maps aka dictionary

I'd like to have a container in cpp that kind of behaves like python dictionaries do, at least in the following regards: key-value structure (key might be restricted to a single type) variadic value ...
mzoll's user avatar
  • 475
1 vote
0 answers
110 views

C++ std::streambuf::pubseekpos(): check if random access is supported

While writing a generic function taking a reference to an std::streambuf, I'd like to check if the supplied buffer is tied to something supporting random access or not and optimize the treatment ...
tomoyo255's user avatar
  • 143
2 votes
4 answers
779 views

Is there a trait that works for both VecDeque and Vec?

We can pass a Vec<f64> to this function, but we cannot pass a VecDeque, because that is two slices: fn mean(v: &[f64]) -> f64 { let sum = v.iter().sum(); sum / v.len() as f64 } ...
user14717's user avatar
  • 4,664
0 votes
0 answers
96 views

C++ file-backed, tree-like datastructure

I'm currently using google's protobuffer library to store and load data from disk. It's pretty convenient because it's fast, provides a nice way of defining my datastructures, allows to compress/...
matthias_buehlmann's user avatar
1 vote
3 answers
18k views

How to efficiently merge two lists in Java?

There are several ways to merge lists in Java You can call to ArrayList(Collection<? extends E> c) You can use the stream API, like Stream.concat() or Stream.of(listA, listB).forEach() and more....
Ilya Gazman's user avatar
  • 31.1k
0 votes
0 answers
925 views

Read Data from RAM in python

I want to read the data from RAM (Random Access Memory) in python. I know this is a vague question. But I am eager to know how do you do it. I use Microsoft Windows 10 and Programming language Python ...
Siddarth Kumar Jha's user avatar
0 votes
1 answer
457 views

Why is random access of deque O(1) time

I've read STL deque accessing by index is O(1)? and how does random access of an element in deque gives constant time complexity? and it still doesn't seem clear to me why O(1) random access is ...
user5965026's user avatar
0 votes
2 answers
137 views

Having trouble writing a structure to a binary file C++

I'm trying to make a code that takes a structure, asks for user info and puts the data into a binary file called "output" so it can be read. I tried doing it with my code but it wasn't working. Can ...
King's user avatar
  • 29
1 vote
1 answer
705 views

Difference between read and seek (Random Access)

I do not quite understand what is the difference from read and seek. My prof says that seek is a more advanced version of read, which separates the "movement from the operation". But unfortunately, I ...
Marine Biologist Kujo's user avatar
0 votes
1 answer
240 views

How to read a text file from the beginning up to a certain point. C++

So I'm working on some work for a class that discusses random access files. One of the questions (Option 3) asks us to create a code that takes a text file and read and displays its contents from the ...
King's user avatar
  • 29
1 vote
1 answer
212 views

What containers are valid to use with std::random_shuffle?

What containers are valid to use with std::random_shuffle( RandomIt first, RandomIt last )? The API description says the two iterators need to be random-access iterators -- I guess I'm not clear what ...
StoneThrow's user avatar
  • 5,204
0 votes
1 answer
229 views

How setLength to RandomAccessFile without write it?

I am running the following piece of code: RandomAccessFile randomAccessFile = new RandomAccessFile(new File(Download.DESTINATION + Download.getFileName(Download.FILEPATH)), "rwd"); ...
Cherry's user avatar
  • 30.7k
2 votes
0 answers
96 views

How to write a line or block in the middle of bgzf

I'd like to reference the following post as well, and mention that I'm familiar with BioPython. How to obtain random access of a gzip compressed file I'm familiar with the Bio.bgzf's potential for ...
BioInfoDevelopment's user avatar
1 vote
2 answers
806 views

Shouldn't C++ Map be a random access data structure, rather than a bidirectional access data structure?

Why is map a bidirectional data structure. We can easily access any element if we know by using its key, just like a array which is a random access data structure? Then should not a map be a random ...
muditrustagii's user avatar
0 votes
2 answers
89 views

quick random row in PostgreSQL: why time (floor(random()*N)) + (select * from a where id = const) 100 times less then select where id = random?

I need to quickly select row from PostgreSQL query. I've read Best way to select random rows PostgreSQL . quick random row selection in Postgres By far quickest of I've read is: CREATE EXTENSION ...
Alex Martian's user avatar
  • 3,354
0 votes
3 answers
803 views

What is the best way to read large file (>2GB) (Text file contains ethernet data) and access the data randomly by different parameters?

I have a text file which looks like below: 0.001 ETH Rx 1 1 0 B45678810000000000000000AF0000 555 0.002 ETH Rx 1 1 0 B45678810000000000000000AF 23 0.003 ETH Rx 1 1 0 B45678810000000000000000AF156500 0....
Bhargava's user avatar
1 vote
1 answer
837 views

How to properly iterate a 3D vector, using only iterators in C++? [closed]

I have the following main() program - int main() { vector<vector<vector<int> > > vec; vector<vector<int> > vv; vector<int> ve; //fill vectors ...
Vikram Singh's user avatar
3 votes
0 answers
248 views

Why does executing iterator->end() in the immediate window give read access violation, even when the iterator is in scope - for C++ vector::iterator?

I have the following program: int main() { vector<vector<int> > vv; vector<int> v1; vector<int> v2; v1.push_back(1); v1.push_back(2); v1.push_back(3); ...
Vikram Singh's user avatar
2 votes
1 answer
400 views

For C++ Random Access Iterator (vector iterator), how is the difference between iterators calculated?

I have following code to randomize the elements in a Random Access Iterator (vector<int>::iterator) - #include <vector> #include <list> #include <iterator> #include <...
Vikram Singh's user avatar
0 votes
1 answer
1k views

For Random Access Iterator (vector iterator), are the iterators C++ style pointers?

I have the following code to randomize the elements in a list container: #include <vector> #include <list> #include <iterator> #include <algorithm> #...
Vikram Singh's user avatar
1 vote
1 answer
62 views

Why are "random" numbers plugged from memory often extremely large?

Sometimes during development of e.g. C code, you may accidentally index an array beyond its last element, resulting in a read of an essentially "random" chunk of memory. I work a lot with ...
jmd_dk's user avatar
  • 11.9k
2 votes
2 answers
680 views

SFINAE - detect if type T is pointer, array or container with random access operator and for given value type

I am fighting with SFINAE trying to have many functions that requires just to have access to the type T with operator []. So far I have the following code that compiles and works fine with Visual ...
Baj Mile's user avatar
  • 740
0 votes
1 answer
61 views

Is it reasonable to fudge the iterator category if my container falls between two of the existing values?

I have a rope container using a self-balancing order-statistic tree as its underlying storage (each tree node containing a variable but in general fairly numerous elements of the rope, for example if ...
SoronelHaetir's user avatar
1 vote
0 answers
198 views

How can I randomly access text from bzip2 files?

I've been using James Taylor's bzip-seek2 script for randomly accessing the content of .bz2 files. Wikipedia dumps all the articles in a single XML file which is compressed using bzip2. I was trying ...
descentis's user avatar
1 vote
2 answers
69 views

How Array/ArrayList goes direct to the index of object? Or How ArrayList get to know that the object is stored at this place?

in the interview room,the interviewer asked me a question that how arraylist is so fast,i said that it implements RandomAccess, but he asked how random access beneficial for searching the object in ...
Abhishek Nathe's user avatar
1 vote
1 answer
169 views

Shuffle huge table in sql3

I am currently using the sqlite3 python package to access data in a table within a DB. The table is quite huge -around 100GB- and I want to randomize its rows, since it contains training data for my ...
Firas_'s user avatar
  • 53
5 votes
0 answers
399 views

Does bzip2, allow random access decompression at block or stream level?

Some other questions here have been about the issue of being able to compress only a part/chunk of a large file of compressed data. Allowing some sort of "random access decompression". Bzip2 has ...
humanityANDpeace's user avatar
1 vote
1 answer
369 views

C data structure suitable for fast search and simple add/remove

As stated in the question header, I need a data structure suitable for fast and efficient searching. The data structure should also be able to add/remove elements to/from anywhere inside the data ...
Mahdi.B's user avatar
  • 57
0 votes
0 answers
130 views

Random Access Stream with JavaScript

I tried to find out if there exists a stream API for random access streams in JavaScript. I was checking the Streams-API and from my understanding there is no classic read(offset, length). From what ...
Philipp's user avatar
  • 2,336
2 votes
0 answers
808 views

Lazy load and play multiple random html5 videos in viewport

I'm creating a webpage to play multiple html5 videos at the same time. I added the lazy load script + visible only script, so only the videos in the viewport will load and play when I scroll. Look at ...
CandyG80's user avatar
0 votes
2 answers
1k views

Appending to binary file after writing to beginning

I'm creating a binary file of records with the following format: quantity-of-records record_1 record_2 ... record_N The issue is that record_1 is overwritten each time, instead of ...
Thomas Matthews's user avatar
0 votes
1 answer
58 views

Random access to array of raw buffers of different sizes?

I have an array of array: struct chunk { char * data; size_t size; }; chunk * chunks;. The data size in each chunk is dynamic and differ between chunks. Linear access to data is easy with a nested for ...
Fred's user avatar
  • 397
0 votes
0 answers
421 views

Mongodb Generate unique random with resultset in Query

i want to generate unique number with each document when i execute query.Below is my query that generate random number,but that number is same to my 20 result set. When again executing number is ...
5a01d01P's user avatar
  • 663
1 vote
1 answer
458 views

Data Structure(s) Allowing For Alteration Through Iteration and Random Selection From Subset (C++)

Given a fixed-sized array A of objects, suppose a much smaller subset of these objects meet a certain criteria B. There are three tasks I want to complete with approximately equal frequency: I want ...
ereHsaWyhsipS's user avatar
1 vote
2 answers
196 views

Randomly select an element from a std::set in O(log(n)) time

Is there a way to randomly select an element from an std::set in O(log(n)) or even better O(1) time? It doesn't need to have an extremely even distribution, just something fairly random (though ...
rtpax's user avatar
  • 1,667
0 votes
1 answer
605 views

Random access in vector in c++ [duplicate]

While trying to randomly access an empty vector in c++, there is segmentation fault. vector<int> g; cout<<g[3]; //Segmentation fault But if we do a single push_back() operation, then we ...
Rajdeep Sarkar's user avatar
1 vote
2 answers
597 views

Is it possible to decipher at random position with nodejs crypto?

My understanding is that an AES block cipher in CTR mode allows, in theory, to decipher any location of a large file, without needing to read the whole file. However, I don't see how to do this with ...
youen's user avatar
  • 1,922
4 votes
2 answers
672 views

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__(...
Mad Physicist's user avatar

1
2 3 4 5
7