Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MemoryManager {
- private HashMap<String, Object> heap = new HashMap<String, Object>();
- private Integer maxSize = 0;
- public class LimitIsExceeded extends Exception {
- }
- public MemoryManager(int maxSize) {
- this.maxSize = maxSize;
- }
- public void let(string name, object value) throws LimitIsExceeded {
- if(heap.size() >= maxSize && !heap.containsKey(name)) {
- throw new LimitIsExceeded();
- } heap.put(name, value);
- }
- public void get(string name) {
- heap.get(name);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement