• R/O
  • SSH
  • HTTPS

eirrepo: Commit


Commit MetaInfo

Revision180 (tree)
Time2018-12-28 21:38:51
Authorquiret

Log Message

- removed some stupid conventions that turned out too complicated
- fixed a small bug
- added two new functions to prepare nodes for insertion and to decommission nodes that you do not need anymore (eir::SortedSliceSector)

Change Summary

Incremental Difference

--- common/sdk/SortedSliceSector.h (revision 179)
+++ common/sdk/SortedSliceSector.h (revision 180)
@@ -77,11 +77,12 @@
7777 {
7878 // REQUIREMENTS FOR metaDataType TYPE:
7979 // * constructor( eir::mathSlice <numberType> slice, ... );
80- // * constructor( const metaDataType& metaData );
80+ // * copy-constructor;
81+ // * move-constructor;
8182 // * sectorSlice_t GetNodeSlice( void ) const;
82- // * template <typename... systemArgs> void Remove( systemArgs... args );
83- // * template <typename... updateArgs> bool IsMergeable( updateArgs... args ) const;
84- // * template <typename... updateArgs> void Update( const sectorSlice_t& newSlice, updateArgs... args );
83+ // * void Remove( void );
84+ // * template <typename... constrArgs> bool IsMergeable( constrArgs... args ) const;
85+ // * void Update( const sectorSlice_t& newSlice );
8586
8687 typedef mathSlice <numberType> sectorSlice_t;
8788
@@ -311,7 +312,7 @@
311312 if ( subtractSlice != remainder )
312313 {
313314 // Set the new validity region.
314- subtractNode->metaData.Update( remainder, args... );
315+ subtractNode->metaData.Update( remainder );
315316 }
316317
317318 // Reinsert into the tree.
@@ -324,7 +325,7 @@
324325 // Spawn a new node.
325326 metaDataType metaData( subtractNode->metaData );
326327
327- metaData.Update( remainder, args... );
328+ metaData.Update( remainder );
328329
329330 insertToTreeNode = new_node( std::move( metaData ) );
330331 }
@@ -345,7 +346,7 @@
345346 // Did the region actually change?
346347 if ( hostRegion != newSlice )
347348 {
348- hostOfMerge->metaData.Update( std::move( newSlice ), std::forward <constrArgs> ( args )... );
349+ hostOfMerge->metaData.Update( std::move( newSlice ) );
349350 }
350351 }
351352 else
@@ -365,8 +366,7 @@
365366 MergeSlice( std::move( slice ), nullptr, sectorSlice_t(), std::forward <constrArgs> ( args )... );
366367 }
367368
368- template <typename... constrArgs>
369- inline void Remove( sectorSlice_t slice, constrArgs... args )
369+ inline void Remove( sectorSlice_t slice )
370370 {
371371 // While we find any intersection we remove areas from said nodes.
372372 while ( AVLNode *avlFoundNode = this->data.avlSliceTree.FindNodeCustom <nodeWithoutNeighborComparator> ( slice ) )
@@ -386,7 +386,7 @@
386386 {
387387 if ( isFirst )
388388 {
389- foundNode->metaData.Update( newSlice, args... );
389+ foundNode->metaData.Update( newSlice );
390390
391391 this->data.avlSliceTree.Insert( avlFoundNode );
392392
@@ -395,8 +395,12 @@
395395 else
396396 {
397397 // Must spawn a new node.
398- sliceNode *newNode = new_node( newSlice, args... );
398+ metaDataType metaData( foundNode->metaData );
399399
400+ metaData.Update( newSlice );
401+
402+ sliceNode *newNode = new_node( std::move( metaData ) );
403+
400404 try
401405 {
402406 this->data.avlSliceTree.Insert( &newNode->node );
@@ -413,7 +417,7 @@
413417 if ( !didHaveFirst )
414418 {
415419 // Remove us.
416- foundNode->metaData.Remove( args... );
420+ foundNode->metaData.Remove();
417421
418422 del_node( foundNode );
419423 }
@@ -430,14 +434,13 @@
430434 return ( this->data.avlSliceTree.GetRootNode() == nullptr );
431435 }
432436
433- template <typename... removalArgs>
434- AINLINE void Clear( removalArgs... args )
437+ AINLINE void Clear( void )
435438 {
436439 while ( AVLNode *avlCurNode = this->data.avlSliceTree.GetRootNode() )
437440 {
438441 sliceNode *curNode = AVL_GETITEM( sliceNode, avlCurNode, node );
439442
440- curNode->metaData.Remove( args... );
443+ curNode->metaData.Remove();
441444
442445 this->data.avlSliceTree.RemoveByNode( avlCurNode );
443446
@@ -517,7 +520,7 @@
517520 {
518521 const sectorSlice_t unavailSlice = sectorSlice_t::fromBounds( curStartBound, GetTightBound( curSlice.GetSliceStartBound() ) );
519522
520- cb( unavailSlice, false );
523+ cb( unavailSlice, nullptr );
521524 }
522525
523526 // Update the current start point.
@@ -531,7 +534,7 @@
531534 {
532535 if ( availableSliceWhole )
533536 {
534- cb( (const sectorSlice_t&)curSlice, true );
537+ cb( (const sectorSlice_t&)curSlice, (const metaDataType*)&curNode->metaData );
535538 }
536539 else
537540 {
@@ -543,7 +546,7 @@
543546 assert( gotShared == true );
544547 #endif //_DEBUG
545548
546- cb( (const sectorSlice_t&)objSharedSlice, true );
549+ cb( (const sectorSlice_t&)objSharedSlice, (const metaDataType*)&curNode->metaData );
547550 }
548551 }
549552
@@ -560,7 +563,7 @@
560563 curSlice = curNode->GetNodeSlice();
561564
562565 // Is that node still in the region?
563- eCompResult cmpRes = _CompareSlices( curSlice, sliceShared, false );
566+ eCompResult cmpRes = _CompareSlices( curSlice, sliceShared, nullptr );
564567
565568 if ( cmpRes != eCompResult::EQUAL )
566569 {
@@ -608,6 +611,28 @@
608611 MergeSlice( hostRegion, node, hostRegion, std::forward <constrArgs> ( args )... );
609612 }
610613
614+ // If you want to prepare a node to be added to the slices.
615+ template <typename... constrArgs>
616+ AINLINE metaDataType* PrepareDecommittedNode( sectorSlice_t slice, constrArgs... args )
617+ {
618+ sliceNode *newNode = new_node( std::move( slice ), std::forward <constrArgs> ( args )... );
619+
620+ return &newNode->metaData;
621+ }
622+
623+ // For garbage-canning any nodes. Can also be used on detached nodes.
624+ template <typename... constrArgs>
625+ AINLINE void DeleteDecommittedNode( metaDataType *data )
626+ {
627+ sliceNode *node = LIST_GETITEM( sliceNode, data, metaData );
628+
629+#ifdef _DEBUG
630+ assert( this->data.avlSliceTree.IsNodeInsideTree( &node->node ) == false );
631+#endif //_DEBUG
632+
633+ del_node( node );
634+ }
635+
611636 private:
612637 static AINLINE eCompResult _CompareSlices( const sectorSlice_t& leftSlice, const sectorSlice_t& rightSlice, bool doCountInNeighbors )
613638 {
Show on old repository browser