// Path: src/main/java/tr/com/serkanozal/mysafe/AllocatedMemoryIterator.java
// public interface AllocatedMemoryIterator {
// 
//     /**
//      * Called for each allocated memory.
//      * 
//      * @param address   address of the allocated memory
//      * @param size      size of the allocated memory
//      */
//     void onAllocatedMemory(long address, long size);
//     
// }
// 
// Path: src/main/java/tr/com/serkanozal/mysafe/AllocatedMemoryStorage.java
// public interface AllocatedMemoryStorage {
//     
//     /**
//      * Represents any invalid value.
//      */
//     long INVALID = -1;
//     
//     /**
//      * Checks if the given address is allocated or not.
//      * 
//      * @param address the address to be checked if it is allocated or not
//      * @return <code>true</code> if if the given address is allocated, 
//      *         otherwise <code>false</code>
//      */
//     boolean contains(long address);
//     
//     /**
//      * Checks if the specified memory region starting from given address 
//      * as given size is in allocated memory area or not.
//      * 
//      * @param address   the start address of the specified memory region
//      * @param size      the size of the specified memory region
//      * @return <code>true</code> if if the given specified memory region 
//      *         is in allocated memory area, otherwise <code>false</code>
//      */
//     boolean contains(long address, long size);
//     
//     /**
//      * Gets the allocation size of the given address.
//      * 
//      * @param address the address whose allocation size will be retrieved
//      * @return allocation size of the given address if it is exist (allocated), 
//      *         otherwise {@link AllocatedMemoryStorage#INVALID}
//      */
//     long get(long address);
//     
//     /**
//      * Stores given address with its allocation size.
//      * 
//      * @param address   the address
//      * @param size      the allocation size
//      */
//     void put(long address, long size);
//     
//     /**
//      * Removes the given address.
//      * 
//      * @param address the address to be removed
//      * @return allocation size of the removed address if it is exist (allocated), 
//      *         otherwise {@link AllocatedMemoryStorage#INVALID}
//      */
//     long remove(long address);
//     
//     /**
//      * Iterates on the allocated memory addresses.
//      * 
//      * @param iterator the {@link AllocatedMemoryIterator} instance to be notified 
//      *                 for each allocated memory while iterating
//      */
//     void iterate(AllocatedMemoryIterator iterator);
//     
//     /**
//      * Returns <tt>true</tt> if storage is empty, otherwise returns <tt>false</tt>.
//      * 
//      * @return <tt>true</tt> if storage is empty, <tt>false</tt> otherwise
//      */
//     boolean isEmpty();
//     
// }


import java.util.Map;
import org.cliffc.high_scale_lib.NonBlockingHashMapLong;
import tr.com.serkanozal.mysafe.AllocatedMemoryIterator;
import tr.com.serkanozal.mysafe.AllocatedMemoryStorage;
            }
        } 
        return false;
    }
    
    @Override
    public boolean contains(long address, long size) {
        for (Map.Entry<Long, Long> entry : allocatedMemories.entrySet()) {
            long startAddress = entry.getKey();
            long endAddress = startAddress + entry.getValue();
            if (address >= startAddress && (address + size) <= endAddress) {
                return true;
            }
        }
        return false;
    }

    @Override
    public long get(long address) {
        Long size = allocatedMemories.get(address);
        return size != null ? size : INVALID;
    }

    @Override
    public void put(long address, long size) {
        allocatedMemories.put(address, (Long) size);
    }

    @Override
    public long remove(long address) {
// Path: src/main/java/tr/com/serkanozal/mysafe/AllocatedMemoryIterator.java
// public interface AllocatedMemoryIterator {
// 
//     /**
//      * Called for each allocated memory.
//      * 
//      * @param address   address of the allocated memory
//      * @param size      size of the allocated memory
//      */
//     void onAllocatedMemory(long address, long size);
//     
// }
// 
// Path: src/main/java/tr/com/serkanozal/mysafe/AllocatedMemoryStorage.java
// public interface AllocatedMemoryStorage {
//     
//     /**
//      * Represents any invalid value.
//      */
//     long INVALID = -1;
//     
//     /**
//      * Checks if the given address is allocated or not.
//      * 
//      * @param address the address to be checked if it is allocated or not
//      * @return <code>true</code> if if the given address is allocated, 
//      *         otherwise <code>false</code>
//      */
//     boolean contains(long address);
//     
//     /**
//      * Checks if the specified memory region starting from given address 
//      * as given size is in allocated memory area or not.
//      * 
//      * @param address   the start address of the specified memory region
//      * @param size      the size of the specified memory region
//      * @return <code>true</code> if if the given specified memory region 
//      *         is in allocated memory area, otherwise <code>false</code>
//      */
//     boolean contains(long address, long size);
//     
//     /**
//      * Gets the allocation size of the given address.
//      * 
//      * @param address the address whose allocation size will be retrieved
//      * @return allocation size of the given address if it is exist (allocated), 
//      *         otherwise {@link AllocatedMemoryStorage#INVALID}
//      */
//     long get(long address);
//     
//     /**
//      * Stores given address with its allocation size.
//      * 
//      * @param address   the address
//      * @param size      the allocation size
//      */
//     void put(long address, long size);
//     
//     /**
//      * Removes the given address.
//      * 
//      * @param address the address to be removed
//      * @return allocation size of the removed address if it is exist (allocated), 
//      *         otherwise {@link AllocatedMemoryStorage#INVALID}
//      */
//     long remove(long address);
//     
//     /**
//      * Iterates on the allocated memory addresses.
//      * 
//      * @param iterator the {@link AllocatedMemoryIterator} instance to be notified 
//      *                 for each allocated memory while iterating
//      */
//     void iterate(AllocatedMemoryIterator iterator);
//     
//     /**
//      * Returns <tt>true</tt> if storage is empty, otherwise returns <tt>false</tt>.
//      * 
//      * @return <tt>true</tt> if storage is empty, <tt>false</tt> otherwise
//      */
//     boolean isEmpty();
//     
// }


// Path: src/main/java/tr/com/serkanozal/mysafe/impl/storage/DefaultAllocatedMemoryStorage.java
import java.util.Map;
import org.cliffc.high_scale_lib.NonBlockingHashMapLong;
import tr.com.serkanozal.mysafe.AllocatedMemoryIterator;
import tr.com.serkanozal.mysafe.AllocatedMemoryStorage;

            }
        } 
        return false;
    }
    
    @Override
    public boolean contains(long address, long size) {
        for (Map.Entry<Long, Long> entry : allocatedMemories.entrySet()) {
            long startAddress = entry.getKey();
            long endAddress = startAddress + entry.getValue();
            if (address >= startAddress && (address + size) <= endAddress) {
                return true;
            }
        }
        return false;
    }

    @Override
    public long get(long address) {
        Long size = allocatedMemories.get(address);
        return size != null ? size : INVALID;
    }

    @Override
    public void put(long address, long size) {
        allocatedMemories.put(address, (Long) size);
    }

    @Override
    public long remove(long address) {
        Long size = allocatedMemories.remove(address);