// m_primaryBuffer
m_buffer(m_primaryBuffer),
m_length(0),
- m_capacity(sizeof m_primaryBuffer - 1)
+ m_capacity(sizeof m_primaryBuffer - 1),
+ m_reallocation(0)
{
m_buffer[0] = '\0';
}
// m_primaryBuffer
m_buffer(m_primaryBuffer),
m_length(0),
- m_capacity(sizeof m_primaryBuffer)
+ m_capacity(sizeof m_primaryBuffer),
+ m_reallocation(0)
{
m_buffer[0] = '\0';
append(source);
// m_primaryBuffer
m_buffer(m_primaryBuffer),
m_length(0),
- m_capacity(sizeof m_primaryBuffer)
+ m_capacity(sizeof m_primaryBuffer),
+ m_reallocation(0)
{
m_buffer[0] = '\0';
append(source, sourceLength);
// m_primaryBuffer
m_buffer(m_primaryBuffer),
m_length(0),
- m_capacity(sizeof m_primaryBuffer)
+ m_capacity(sizeof m_primaryBuffer),
+ m_reallocation(0)
{
append(source.buffer(), source.length());
}
delete[] m_buffer;
m_buffer = buffer;
m_capacity = size;
+ m_reallocation++;
}
}
/**
rc = indexOf(head, headLength, 0, headLength, ignoreCase) == 0;
return rc;
}
+
+/**
+ * Appends the status data of the instance onto the buffer.
+ *
+ * @param buffer OUT: the space for the data report
+ * @param prefix NULL or a prefix of the output
+ * @return <code>buffer.str()</code> (for chaining)
+ */
+const char* ReByteBuffer::status(ReByteBuffer& buffer, const char* prefix){
+ if (prefix != NULL)
+ buffer.append(prefix);
+ buffer.append("capacity:").appendInt(m_capacity)
+ .append(" length: ").appendInt(m_length)
+ .append(" realloc: ").appendInt(m_reallocation).append("\n");
+ return buffer.str();
+}
+
bool splice(size_t ix, size_t replacedLength, const Byte* source, size_t length);
bool startsWith(const Byte* head, size_t headLength = -1,
const bool ignoreCase = false) const;
-
+ const char* status(ReByteBuffer& buffer, const char* prefix = NULL);
/** @brief Returns the buffer content as C string.
* This is exactly the same result as from <code>getBuffer()</code>.
* @return The internal used buffer.
size_t m_length;
//@ The size of <code>m_buffer</code>.
size_t m_capacity;
+ //@ number of reallocation in ensureSize()
+ int m_reallocation;
};
#endif /* REBYTEBUFFER_H_ */
m_values.setCapacity(maxKeys, contentSpace);
}
+/**
+ * Appends the status data of the instance onto the buffer.
+ *
+ * @param buffer OUT: the space for the data report
+ * @param prefix NULL or a prefix of the output
+ * @return <code>buffer.str()</code> (for chaining)
+ */
+const char* ReHashList::status(ReByteBuffer& buffer, const char* prefix){
+ if (prefix != NULL)
+ buffer.append(prefix).append("\n", 1);
+ m_keys.status(buffer, "keys: ");
+ m_values.status(buffer, "values: ");
+ return buffer.str();
+}
+
void put(const char* key, const char* value);
void put(const ReByteBuffer& key, const ReByteBuffer& value);
void setCapacity(int maxKeys, int keySpace, int contentSpace);
+ const char* status(ReByteBuffer& buffer, const char* prefix = NULL);
protected:
int find(const Byte* key, size_t length) const;
m_offsetOfTag(sizeof(Index) + 1),
m_offsetOfLength(sizeof(Index)),
m_sorted(false),
- m_ignoreCase(false)
+ m_ignoreCase(false),
+ m_age(0)
{
}
/** @brief Destructor.
m_offsetOfTag(source.m_offsetOfTag),
m_offsetOfLength(source.m_offsetOfLength),
m_sorted(source.m_sorted),
- m_ignoreCase(false)
+ m_ignoreCase(false),
+ m_age(0)
{
}
/** @brief Assignment operator.
setSequence(&seq, m_content.length(), sourceLength, tag);
m_content.append(source, sourceLength);
Index rc = index;
+ m_age++;
if (m_sorted && index == (Index) -1){
binarySearch(source, sourceLength, rc);
m_list.insert(rc * m_entrySize, (Byte*) &seq, m_entrySize);
if (length < 0)
length = strlen(toFind);
bool rc = false;
- int lbound = 0;
+ int lbound = 0;
int theCount = count();
int ubound = theCount - 1;
int compareRc = 0;
void ReSeqArray::clear(){
m_content.setLength(0);
m_list.setLength(0);
+ m_age++;
}
/**
*/
void ReSeqArray::remove(Index index){
if (index <= count()){
+ m_age++;
Sequence* seq = getInfo(index);
size_t currentLength = getLength(seq);
// Is this the last entry in m_content?
if (index >= count())
add(index, source, sourceLength, tag);
else {
+ m_age++;
if (sourceLength == (size_t) -1)
sourceLength = strlen(source) + 1;
Sequence* seq = getInfo(index);
void ReSeqArray::sort(){
// Build the heap in array so that largest value is at the root:
int theCount = (int) count();
+ m_age++;
for (int start = (theCount - 2) / 2; start >= 0; start--) {
// (shift down the node at index 'start' to the proper place such
// that all nodes below the start index are in heap order)
shiftDown(0, end);
}
}
+/**
+ * Appends the status data of the instance onto the buffer.
+ *
+ * @param buffer OUT: the space for the data report
+ * @param prefix NULL or a prefix of the output
+ * @return <code>buffer.str()</code> (for chaining)
+ */
+const char* ReSeqArray::status(ReByteBuffer& buffer, const char* prefix){
+ if (prefix != NULL)
+ buffer.append(prefix);
+ buffer.append("age: ").appendInt(m_age).append("\n");
+ m_list.status(buffer, "list: ");
+ m_content.status(buffer, "content: ");
+ return buffer.str();
+}
+
/**
* Correct the order in the heap.
*
void setSorted(bool onNotOff);
void setIgnoreCase(bool onNotOff);
void sort();
+ const char* status(ReByteBuffer& buffer, const char* prefix = NULL);
protected:
/** @brief Returns a pointer of the content buffer.
* @return A pointer of the first byte of the content buffer.
bool m_sorted;
//@ true: the comparison will be case insensitive
bool m_ignoreCase;
+ //@ number of modifications (insert/replace/remove)
+ int m_age;
};
#endif /* RESEQLIST_H_ */
maxKeys, key.setLength(0).appendMilliSec(duration1).str(),
countGet, value.setLength(0).appendMilliSec(duration2).str(),
collisions);
+ log(false, hash.status(value.setLength(0)));
}
void testBasic(){
ReHashList hash;
}
void run(){
initTree();
+
+ testToolStatistic();
testBasic();
testDirOptions();
checkSetFilterFromProgramArgs();
checkT(buffer.startsWith(" 0.000087 MB 5 6\t"));
expected.set(m_base.str(), m_base.length());
}
+ void testToolStatistic(){
+ ReDirTools tools;
+ const char* argv[] = { "dt", "stat", "-P;*;-*/cache/*", m_base.str(), "2" };
+ tools.main(5, (char**) argv);
+ }
};
extern void testReTraverser(void);
void testAll(){
try
{
- testOs();
testBase();
+ testOs();
testMath();
testString();
} catch (ReException e){
m_programArgs.addInt("mindepth",
i18n("the depth of the subdirectory is greater or equal <number>\n"
"0: search is done in all subdirectories"),
- 'd', "min-depth", 512);
+ 'd', "min-depth", 0);
m_programArgs.addString("output",
i18n("the name of the output file.\n"
"The output will written to this file instead of stdout"),