19package denoptim.utils;
22import java.io.IOException;
23import java.util.Collections;
24import java.util.HashSet;
27import denoptim.exception.DENOPTIMException;
28import denoptim.files.FileUtils;
29import denoptim.io.DenoptimIO;
87 this.dataOnDisk =
new File(memoryFile);
88 if (allUIDsFile!=
null)
89 this.allData =
new File(allUIDsFile);
90 data = Collections.synchronizedSet(
new HashSet<String>());
110 boolean wasNew =
false;
113 if (
data.contains(entry))
123 wasNew =
data.add(entry);
135 throw ((IOException) e.getCause());
152 public synchronized boolean contains(String entry)
throws IOException
156 boolean foundInMemory =
data.contains(entry);
157 boolean foundInDisk =
false;
163 return foundInMemory || foundInDisk;
static boolean isLineInTxtFile(String query, File file, boolean add)
Search in a file for a line matching the given string query.
Utility methods for input/output.
static void writeData(String fileName, String data, boolean append)
Write text-like data file.
Class meant to collect unique strings without leading to memory overflow.
synchronized int size()
Returns the number of unique entries.
int entriesInFile
Number of entries written to file.
synchronized boolean contains(String entry)
Checks if an entry is contained in this collection.
File allData
The file used to store all entries on disk.
File dataOnDisk
The file used to deal with entries that do not fit in the maximum size of this set.
synchronized boolean addNewUniqueEntry(String entry)
Checks if the given entry is already container in the set of known entries and, if not,...
SizeControlledSet(int maxSize, String memoryFile, String allUIDsFile)
Constructor for a size-controlled storage of unique Strings.
boolean usingDisk
Flag signalling the use of the disk.
Set< String > data
The actual data collection.
int maxSize
Maximum size of the set.