The AppenderTable illustrates one possible implementation of
an Table possibly containing a great many number of rows.
In this particular example we use a fixed size buffer
(CyclicBuffer) although this data structure could be easily
replaced by dynamically growing one, such as a Vector. The required
properties of the data structure is 1) support for indexed element
access 2) support for the insertion of new elements at the end.
Experimentation on my 1400Mhz AMD machine show that it takes
about 45 micro-seconds to insert an element in the table. This
number does not depend on the size of the buffer. It takes as much
(or as little) time to insert one million elements to a buffer of
size 10 as to a buffer of size 10'000. It takes about 4 seconds to
insert a total of 100'000 elements into the table.
On windows NT the test will run about twice as fast if you give
the focus to the window that runs "java AppenderTable" and not the
window that contains the Swing JFrame. |