Class FileLinesBigList

All Implemented Interfaces:
BigList<MutableString>, ObjectBigList<MutableString>, ObjectCollection<MutableString>, ObjectIterable<MutableString>, Size64, Stack<MutableString>, Serializable, Comparable<BigList<? extends MutableString>>, Iterable<MutableString>, Collection<MutableString>, RandomAccess

public class FileLinesBigList extends AbstractObjectBigList<MutableString> implements RandomAccess, Serializable
A wrapper exhibiting the lines of a file as a big list.

An instance of this class allows to access the lines of a file as a BigList. Contrarily to a big FileLinesMutableStringIterable, direct access is possible and reasonably efficient, in particular when accessing nearby lines, and all returned mutable strings are separate, independent instances.

Similarly to FileLinesMutableStringIterable, instead, AbstractObjectBigList.iterator() can be called any number of times, as it opens an independent input stream at each call. For the same reason, the returned iterator type (FileLinesBigList.FileLinesIterator) is Closeable, and should be closed after usage.

Note that toString() will return a single string containing all file lines separated by the string associated to the system property line.separator.

Warning: this class is not synchronised. Separate iterators use separate input streams, and can be accessed concurrently, but all calls to get(long) refer to the same input stream.

Implementation details

Instances of this class perform a full scan of the specified file at construction time, representing the list of pointers to the start of each line using the Elias–Fano representation. The memory occupation per line is thus bounded by 2 + log ℓ bits, where ℓ is the average line length.

Since:
2.1
Author:
Sebastiano Vigna
See Also: