public PropertyMap replaceCopy(Property oldValue, Property newValue) { Deque<Property> shelve = new ArrayDeque<>(); PropertyMap current = this; while (!current.isEmpty()) { if (current.getLastProperty().equals(oldValue)) { PropertyMap newMap = current.getParentMap(); newMap = newMap.putCopy(newValue); for (Property property : shelve) { newMap = newMap.putCopy(property); } return newMap; } else { shelve.push(current.getLastProperty()); current = current.getParentMap(); } } return this; }
public PropertyMap removeCopy(Property value) { Deque<Property> shelve = new ArrayDeque<>(); PropertyMap current = this; while (!current.isEmpty()) { if (current.getLastProperty().equals(value)) { PropertyMap newMap = current.getParentMap(); for (Property property : shelve) { newMap = newMap.putCopy(property); } return newMap; } else { shelve.push(current.getLastProperty()); current = current.getParentMap(); } } return this; }
/** * Create a new shape that adds a property to the parent shape. */ private static ShapeImpl makeShapeWithAddedProperty(ShapeImpl parent, AddPropertyTransition addTransition) { Property addend = addTransition.getProperty(); BaseAllocator allocator = parent.allocator().addLocation(addend.getLocation()); PropertyMap newPropertyMap = parent.propertyMap.putCopy(addend); ShapeImpl newShape = parent.createShape(parent.layout, parent.sharedData, parent, parent.objectType, newPropertyMap, addTransition, allocator, parent.id); assert ((LocationImpl) addend.getLocation()).primitiveArrayCount() == 0 || newShape.hasPrimitiveArray; assert newShape.depth == allocator.depth; return newShape; }
/** * Create a new shape that adds a property to the parent shape. * * @since 0.17 or earlier */ protected static ShapeImpl makeShapeWithAddedProperty(ShapeImpl parent, AddPropertyTransition addTransition) { Property addend = addTransition.getProperty(); BaseAllocator allocator = parent.allocator().addLocation(addend.getLocation()); PropertyMap newPropertyMap = parent.propertyMap.putCopy(addend); ShapeImpl newShape = parent.createShape(parent.layout, parent.sharedData, parent, parent.objectType, newPropertyMap, addTransition, allocator, parent.id); assert ((LocationImpl) addend.getLocation()).primitiveArrayCount() == 0 || newShape.hasPrimitiveArray; assert newShape.depth == allocator.depth; return newShape; }
/** * Create a new shape that adds a property to the parent shape. * * @since 0.17 or earlier */ protected static ShapeImpl makeShapeWithAddedProperty(ShapeImpl parent, AddPropertyTransition addTransition) { Property addend = addTransition.getProperty(); BaseAllocator allocator = parent.allocator().addLocation(addend.getLocation()); PropertyMap newPropertyMap = parent.propertyMap.putCopy(addend); ShapeImpl newShape = parent.createShape(parent.layout, parent.sharedData, parent, parent.objectType, newPropertyMap, addTransition, allocator, parent.id); assert ((LocationImpl) addend.getLocation()).primitiveArrayCount() == 0 || newShape.hasPrimitiveArray; assert newShape.depth == allocator.depth; return newShape; }