Class AbstractNodeDepot
- All Implemented Interfaces:
INodeDepot
- Direct Known Subclasses:
SimpleNodeDepot
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a deep copy: each item is individually copied viaILoad.copy().createWith(List<ILoad> loads) booleanDerived — true if this depot contains at least one flex load.booleanDerived — true if this depot contains at least one timed load.voidinvokeSearchArray(String[] loadIds) booleanReturnstruewhen every item in the depot has a load value of zero (or the depot is empty).Creates a shallow copy: item references are shared, not deep-copied.voidCalled byAbstractGenericDepot.add(T)after a new item is inserted or merged.voidpostAddOnCopy(ILoad item) Called byAbstractGenericDepot.loadItemsDirect(List)once per item on the fast copy/bulk path.booleanRemovesitemfrom the depot and recalculates all derived state.booleanReplacesorgItemwithnewItemand recalculates all derived state.replaceWithCopy(String loadId) protected voidResets all derived boolean flags to their "empty-depot" values before a bulk-load (setItems/loadItemsDirect).voidsetHasFlexLoad(boolean hasFlexLoad) voidsetHasTimedLoads(boolean hasTimedLoads) Methods inherited from class AbstractGenericDepot
add, add, get, getDepotId, getItems, loadItemsDirect, setItemsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface INodeDepot
add, add, createEmptyCopy, get, getDepotId, getItems, setItems, typeName
-
Constructor Details
-
AbstractNodeDepot
-
-
Method Details
-
resetDerivedState
protected void resetDerivedState()Resets all derived boolean flags to their "empty-depot" values before a bulk-load (setItems/loadItemsDirect).Called automatically by
AbstractGenericDepot.loadItemsDirect(List)before the item loop, so thatpostAddOnCopy(ILoad)can rebuild the flags from scratch. Without this reset, a previoustruevalue ofhasFlexibleLoadswould survive a reload with all-simple loads, and a previousfalsevalue ofisZeroLoadwould survive a reload with all-zero loads.- Overrides:
resetDerivedStatein classAbstractGenericDepot<ILoad>
-
postAddOnCopy
Called byAbstractGenericDepot.loadItemsDirect(List)once per item on the fast copy/bulk path. Updates all derived flags from the item, starting from the "empty" baseline established byresetDerivedState().Mirrors
postAdd(ILoad)but is kept separate so that the hot copy path can skip the heavier duplicate-check and merge logic.- Overrides:
postAddOnCopyin classAbstractGenericDepot<ILoad>- Parameters:
item- the item just added to the backing structures
-
postAdd
Called byAbstractGenericDepot.add(T)after a new item is inserted or merged. Flips derived flags fromfalse → trueas needed; never flipsisZeroLoadfromfalseback totrue— that direction requires a full recalculation viarecalcDerivedState().- Specified by:
postAddin classAbstractGenericDepot<ILoad>
-
remove
Removesitemfrom the depot and recalculates all derived state.A simple one-way flag update is insufficient here: removing the last non-zero item must flip
isZeroLoadback totrue, and removing the last flex/timed item must flip those flags back tofalse. A full scan of the remaining items is the only safe approach.- Specified by:
removein interfaceINodeDepot- Overrides:
removein classAbstractGenericDepot<ILoad>- Returns:
trueif the item was present and removed
-
replace
ReplacesorgItemwithnewItemand recalculates all derived state.A non-zero item may be replaced by a zero-value item (the optimizer does this via
replaceWithCopywhen it adjusts flex load values), so a full rescan is necessary.- Overrides:
replacein classAbstractGenericDepot<ILoad>- Returns:
trueiforgItemwas found and replaced
-
hasFlexLoad
public boolean hasFlexLoad()Description copied from interface:INodeDepotDerived — true if this depot contains at least one flex load. Computed at runtime; not a user-settable property.- Specified by:
hasFlexLoadin interfaceINodeDepot
-
setHasFlexLoad
public void setHasFlexLoad(boolean hasFlexLoad) - Specified by:
setHasFlexLoadin interfaceINodeDepot
-
hasTimedLoad
public boolean hasTimedLoad()Description copied from interface:INodeDepotDerived — true if this depot contains at least one timed load. Computed at runtime; not a user-settable property.- Specified by:
hasTimedLoadin interfaceINodeDepot
-
setHasTimedLoads
public void setHasTimedLoads(boolean hasTimedLoads) - Specified by:
setHasTimedLoadsin interfaceINodeDepot
-
isZeroLoad
public boolean isZeroLoad()Returnstruewhen every item in the depot has a load value of zero (or the depot is empty).The result is cached. After a
replace(ILoad, ILoad)call (used byreplaceWithCopy(String)) the cache is marked dirty becauseFlexLoadOperatormutates the returned copy viasetLoadafterreplacehas already returned. The next call to this method rescans the live item list — at that point the mutation has already happened — caches the fresh result, and clears the dirty flag. Subsequent calls are O(1) until the nextreplace.- Specified by:
isZeroLoadin interfaceINodeDepot
-
mergeItem
-
createWith
- Specified by:
createWithin interfaceINodeDepot
-
invokeSearchArray
- Specified by:
invokeSearchArrayin interfaceINodeDepot
-
partialCopy
Creates a shallow copy: item references are shared, not deep-copied.setItemsdelegates toloadItemsDirect, which callsresetDerivedState()thenpostAddOnCopy(ILoad)per item. All derived flags (isZeroLoad,hasFlexibleLoads,hasTimedLoads) are therefore computed correctly from the shared item references without any manual flag assignment.- Specified by:
partialCopyin interfaceINodeDepot
-
copy
Creates a deep copy: each item is individually copied viaILoad.copy().Same flag-recomputation guarantee as
partialCopy().- Specified by:
copyin interfaceINodeDepot
-
replaceWithCopy
- Specified by:
replaceWithCopyin interfaceINodeDepot
-