random-access

RandomAccess Interface, Why no methods?

送分小仙女□ 提交于 2019-12-06 07:08:04
问题 I was reading Collections.shuffle(List) javadoc and then took a look at the RandomAccess javadoc: Marker interface used by List implementations to indicate that they support fast (generally constant time) random access. [...] I am wondering why this interface (like Serializable) does not have methods? What is the design reason for this? Even if only Lists "implement" this interface, why not setting E get() as a method? I know that not every list is random access but how can I use this

random access file in java

蹲街弑〆低调 提交于 2019-12-06 06:21:40
问题 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 examples online, but I either get an EOF exception or random address values when I try to access them. I tried some more examples and couldn't understand the concept very well. I'm trying a project with it and will try to explore more on it. Here is some

Converting Quick BASIC to VB.Net - Random Access Files

[亡魂溺海] 提交于 2019-12-06 02:10:57
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 "test.dat" FOR RANDOM AS #1 LEN = 20 FIELD #1, 10 AS a$, 10 AS b$ LSET a$ = "One" LSET b$ = "Two" PUT #1, 1 GET #1, 1 PRINT a$, b$ CLOSE #1 The Microsoft.VisualBasic.FileOpen , FilePut , and FileGet statements should be pretty direct replacements for most of your code above. Microsoft.VisualBasic.FileOpen(1, "test.dat", OpenMode.Random, OpenAccess

Multi-part gzip file random access (in Java)

余生颓废 提交于 2019-12-06 00:24:55
问题 This may fall in the realm of "not really feasible" or "not really worth the effort" but here goes. I'm trying to randomly access records stored inside a multi-part gzip file. Specifically, the files I'm interested in are compressed Heretrix Arc files. (In case you aren't familiar with multi-part gzip files, the gzip spec allows multiple gzip streams to be concatenated in a single gzip file. They do not share any dictionary information, it is simple binary appending.) I'm thinking it should

Random-access container that does not fit in memory?

梦想与她 提交于 2019-12-05 06:47:56
I have an array of objects (say, images), which is too large to fit into memory (e.g. 40GB). But my code needs to be able to randomly access these objects at runtime. What is the best way to do this? From my code's point of view, it shouldn't matter, of course, if some of the data is on disk or temporarily stored in memory; it should have transparent access: container.getObject(1242)->process(); container.getObject(479431)->process(); But how should I implement this container? Should it just send the requests to a database? If so, which one would be the best option? (If a database, then it

java.io.FileNotFoundException when using RandomAccessFile to create file

僤鯓⒐⒋嵵緔 提交于 2019-12-05 06:18:51
I'm encountering a FileNotFoundException when I try to make a file using RandomAccessFile: RandomAccessFile file = new RandomAccessFile("/test.jpg", "rw"); I don't now how to get around this. It's driving me nuts. Thanks Konstantin Burov Try RandomAccessFile file = new RandomAccessFile(new File(getFilesDir(), "test.jpg"), "rw"); From the documentation: FileNotFoundException - if the mode is "r" but the given file object does not denote an existing regular file, or if the mode begins with "rw" but the given file object does not denote an existing, writable regular file and a new regular file of

Does FileInputStream.skip() do a seek?

a 夏天 提交于 2019-12-04 23:53:30
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 underneath or does it actually read and discard data? I know about RandomAccessFile but I'm interested in whether I could use FileInputStream in place of that (RandomAccessFile is annoying as the API is non-standard). Depends on your JVM, but here's the source for FileInputStream.skip() for a recent openjdk: JNIEXPORT jlong JNICALL Java_java_io

Random access (or otherwise fast access) of edges in boost graph library

眉间皱痕 提交于 2019-12-04 19:32:56
I want to run Monte Carlo edge swaps, i.e., picking two existing edges in a graph uniformly at random and then (if some conditions are met) swap their end points. I am currently using boost::random_edge for selecting edges uniformly at random. #include <boost/graph/adjacency_list.hpp> #include <boost/graph/erdos_renyi_generator.hpp> #include <boost/random/mersenne_twister.hpp> #include <boost/random/variate_generator.hpp> #include <boost/graph/random.hpp> #include <boost/random/linear_congruential.hpp> int main(int argc, char* argv[]) { typedef boost::adjacency_list<boost::setS,boost::vecS

RandomAccess Interface, Why no methods?

岁酱吖の 提交于 2019-12-04 12:30:49
I was reading Collections.shuffle(List) javadoc and then took a look at the RandomAccess javadoc : Marker interface used by List implementations to indicate that they support fast (generally constant time) random access. [...] I am wondering why this interface (like Serializable) does not have methods? What is the design reason for this? Even if only Lists "implement" this interface, why not setting E get() as a method? I know that not every list is random access but how can I use this interface if there is no methods? Something like this: if(object instanceof RandomAccess){ // should I cast

What is the difference between file and random access file?

橙三吉。 提交于 2019-12-04 11:29:13
what is the difference between file and random access file? A random access file is a file where you can "jump" to anywhere within it without having to read sequentially until the position you are interested in. For example, say you have a 1MB file, and you are interested in 5 bytes that start after 100k of data. A random access file will allow you to "jump" to the 100k-th position in one operation. A non-random access file will require you to read 100k bytes first, and only then read the data you're interested in. Hope that helps. Clarification: this description is language-agnostic and does