util
KDevelop::EmbeddedTreeAddItem< Data, ItemHandler, increaseFraction, rebuildIfInsertionMoreExpensive > Class Template Reference
Use this to add items. More...
#include <embeddedfreetree.h>
Public Member Functions | |
| EmbeddedTreeAddItem (Data *items, uint itemCount, int ¢ralFreeItem, const Data &add) | |
| bool | apply (bool force=false) |
| uint | newItemCount () const |
| void | transferData (Data *newItems, uint newCount, int *newCentralFree=0) |
Detailed Description
template<class Data, class ItemHandler, int increaseFraction = 5, int rebuildIfInsertionMoreExpensive = 20>
class KDevelop::EmbeddedTreeAddItem< Data, ItemHandler, increaseFraction, rebuildIfInsertionMoreExpensive >
Use this to add items.
The added item must not be in the set yet! General usage:
- Construct the object
- Check if newItemCount() equals the previous item-count. If not, construct a new list as large as newItemCount, and call object.transferData to transfer the data into the new list. The new size must match the returned newItemCount.
- Either call object.apply(), or let it be called automatically by the destructor.
- Parameters:
-
increaseFraction By what fraction the list is increased when it needs to. For example the size will be increased by 1/5 if it's 5. rebuildIfInsertionMoreExpensive The structure is rebuilt completely when an insertion needs a moving around of more than rebuildIfInsertionMoreExpensive times the count of items needed to be moved in worst case in a fresh tree. After rebuilding the tree, the free space is evenly distributed, and thus insertions require much less moving.
Definition at line 242 of file embeddedfreetree.h.
Member Function Documentation
template<class Data , class ItemHandler , int increaseFraction = 5, int rebuildIfInsertionMoreExpensive = 20>
| bool KDevelop::EmbeddedTreeAddItem< Data, ItemHandler, increaseFraction, rebuildIfInsertionMoreExpensive >::apply | ( | bool | force = false |
) | [inline] |
Tries to put the item into the list. If the insertion would be too inefficient or is not possible, returns false, unless.
- Parameters:
-
force is true
- Todo:
- it's probably better using lowerBound and upperBound like in the "remove" version
Definition at line 332 of file embeddedfreetree.h.
template<class Data , class ItemHandler , int increaseFraction = 5, int rebuildIfInsertionMoreExpensive = 20>
| uint KDevelop::EmbeddedTreeAddItem< Data, ItemHandler, increaseFraction, rebuildIfInsertionMoreExpensive >::newItemCount | ( | ) | const [inline] |
Check this to see whether a new item-count is needed.
If this does not equal the given itemCount, then the data needs to be transferred into a new list using transferData
Definition at line 256 of file embeddedfreetree.h.
template<class Data , class ItemHandler , int increaseFraction = 5, int rebuildIfInsertionMoreExpensive = 20>
| void KDevelop::EmbeddedTreeAddItem< Data, ItemHandler, increaseFraction, rebuildIfInsertionMoreExpensive >::transferData | ( | Data * | newItems, | |
| uint | newCount, | |||
| int * | newCentralFree = 0 | |||
| ) | [inline] |
Transfers the data into a new item-list. The size of the new item-list must equal newItemCount().
- Todo:
- Do not iterate through all items, instead use the free-tree and memcpy for the ranges between free items. Ideally, even the free-tree would be built on-the-fly.
Definition at line 276 of file embeddedfreetree.h.
The documentation for this class was generated from the following file:
KDE 4.4 API Reference