aboutsummaryrefslogtreecommitdiff
path: root/src/unstable/blobbuilder.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2019-06-25 20:00:47 -0700
committerMike Buland <eichlan@xagasoft.com>2019-06-25 20:00:47 -0700
commit14683979c43e17393dc4f902fe65ed22898b2bce (patch)
treee2395ae8de63b41d944c46cae0d2d25266d4377a /src/unstable/blobbuilder.h
parent9e4d15b6dec9a7f9358855faeb96b1ac767a15e6 (diff)
downloadlibbu++-14683979c43e17393dc4f902fe65ed22898b2bce.tar.gz
libbu++-14683979c43e17393dc4f902fe65ed22898b2bce.tar.bz2
libbu++-14683979c43e17393dc4f902fe65ed22898b2bce.tar.xz
libbu++-14683979c43e17393dc4f902fe65ed22898b2bce.zip
BlobBuilder implemented, tests in progress.
Diffstat (limited to 'src/unstable/blobbuilder.h')
-rw-r--r--src/unstable/blobbuilder.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/unstable/blobbuilder.h b/src/unstable/blobbuilder.h
index 483de43..744212a 100644
--- a/src/unstable/blobbuilder.h
+++ b/src/unstable/blobbuilder.h
@@ -61,6 +61,26 @@ namespace Bu
61 }; 61 };
62 /** @endcond */ 62 /** @endcond */
63 63
64 /**
65 * This makes creating a Blob piece at a time easy and fast. You can
66 * append, prepend, or insert with reasonable efficiency. The underlying
67 * data structure is currently a linked list, and the individual links are
68 * actually block allocated memory. If an amount of data is appended that
69 * is less than the minimum page size then the minimum page size is
70 * allocated. Subsequent appends will share that allocated buffer until it
71 * is full, at which point a new buffer will be created. If an amount
72 * greater than the minimum page size is appended then any extra space in
73 * the last buffer is used, and then the rest is placed in a single buffer.
74 * At most one buffer will be allocated for any given append or prepend
75 * operation. Due to the nature of insert, up to two buffers could be
76 * allocated.
77 *
78 * Insert operations will take O(N) time to find the location to insert to
79 * in the linked list, at that point the foud chunk will be split into two
80 * and the new data will be added at the new location. This will also
81 * attempt to share the existing buffers, but if there's extra it will
82 * allocate a new buffer for the remaining data.
83 */
64 class BlobBuilder : public Bu::SharedCore<BlobBuilder, BlobBuilderCore> 84 class BlobBuilder : public Bu::SharedCore<BlobBuilder, BlobBuilderCore>
65 { 85 {
66 protected: 86 protected: