Advertisement
spacerose

pr3 old stuff

Apr 14th, 2021
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.69 KB | None | 0 0
  1.  
  2. //
  3. //    @Override
  4. //    public boolean isEmpty() {
  5. //        boolean f = false;
  6. //        try {
  7. //
  8. //            if (map.length == 0) {
  9. //                semaphore.acquire();
  10. //                f = true;
  11. //                semaphore.release();
  12. //            }
  13. //        } catch (InterruptedException e) {
  14. //            e.printStackTrace();
  15. //        }
  16. //        return f;
  17. //    }
  18. //
  19. //
  20. //    @Override
  21. //    public boolean containsKey(Object key) {
  22. //        boolean f = false;
  23. //        try {
  24. //            for (int i = 0; i < map.length; ++i) {
  25. //                if (key.equals(map[i].get(key))) {
  26. //                    semaphore.acquire();
  27. //                    f = true;
  28. //                    semaphore.release();
  29. //                }
  30. //            }
  31. //        } catch (InterruptedException e) {
  32. //            e.printStackTrace();
  33. //        }
  34. //        return f;
  35. //
  36. //    }
  37. //
  38. //    @Override
  39. //    public boolean containsValue(Object value) {
  40. //        boolean f = false;
  41. //        try {
  42. //            for (HashMap<K, V> m : map) {
  43. //                if (value.equals(m.get(value))) {
  44. //                    semaphore.acquire();
  45. //                    f = true;
  46. //                    semaphore.release();
  47. //                }
  48. //            }
  49. //        } catch (InterruptedException e) {
  50. //            e.printStackTrace();
  51. //        }
  52. //        return f;
  53. //    }
  54. //
  55. //    @Override
  56. //    public V get(Object key) {
  57. //        V q = null;
  58. //        try {
  59. //            for (HashMap<K, V> m : map) {
  60. //                if (key.equals(m.get(key))) q = (m.get(values()));
  61. //                semaphore.acquire();
  62. //                q = m.get(values());
  63. //                semaphore.release();
  64. //            }
  65. //        } catch (InterruptedException e) {
  66. //            e.printStackTrace();
  67. //        }
  68. //        return q;
  69. //    }
  70. //
  71. //    public V put(K key, V value) {
  72. //        if(containsKey(key)){
  73. //            K prevKey;
  74. //            V prevVal = null;
  75. //
  76. //            for (int i = 0; i < map.length; ++i) {
  77. //                if (key.equals(map[i].get(key))){
  78. //                    prevKey= (K) map[i].get(key);
  79. //                    prevVal=map[i].get(value);
  80. //                    map[i]=new HashMap<K,V>((int) prevKey, (float) value);
  81. //                }
  82. //            }
  83. //            return prevVal;
  84. //        }
  85. //        else {
  86. //            HashMap<K, V>[] copy = new HashMap[map.length + 1];
  87. //            for (int i = 0; i < map.length; ++i) {
  88. //                copy[i] = map[i];
  89. //            }
  90. //            copy[map.length] = new HashMap<K,V>((K) key, (V) value);
  91. //            map=copy;
  92. //            return null;
  93. //        }
  94. //    }
  95. //
  96. //
  97. //    @Override
  98. //    public synchronized V remove(Object o) {
  99. //        if (containsKey(o)) {
  100. //            Pair<K, V>[] copy = new Pair[map.length - 1];
  101. //            V prevVal = null;
  102. //            boolean wasKey = false;
  103. //            for (int i = 0; i < map.length; ++i) {
  104. //                if (o.equals(map[i].getKey())) {
  105. //                    wasKey = true;
  106. //                    prevVal = map[i].getValue();
  107. //                    continue;
  108. //                }
  109. //                if (!wasKey) copy[i] = map[i];
  110. //                else copy[i - 1] = map[i];
  111. //            }
  112. //            map = copy;
  113. //            return prevVal;
  114. //        } else return null;
  115. //    }
  116. //
  117. //    @Override
  118. //    public synchronized void putAll(Map addedMap) {
  119. //        Iterator<Entry<K, V>> iterator = addedMap.entrySet().iterator();
  120. //        while (iterator.hasNext()) {
  121. //            Map.Entry<K, V> pair = iterator.next();
  122. //            this.put(pair.getKey(), pair.getValue());
  123. //        }
  124. //    }
  125. //
  126. //    @Override
  127. //    public synchronized void clear() {
  128. //        map = new Pair[0];
  129. //    }
  130. //
  131. //    @Override
  132. //    public synchronized Set<K> keySet() {
  133. //        Set<K> set = null;
  134. //        Iterator<Entry<K, V>> iterator = this.entrySet().iterator();
  135. //        while (iterator.hasNext()) {
  136. //            Entry<K, V> pair = iterator.next();
  137. //            set.add(pair.getKey());
  138. //        }
  139. //        return set;
  140. //    }
  141. //
  142. //    @Override
  143. //    public synchronized Collection values() {
  144. //        Collection<V> collection = new ArrayList<>();
  145. //        for (int i = 0; i < map.length; ++i) {
  146. //            collection.add(map[i].getValue());
  147. //        }
  148. //        return collection;
  149. //    }
  150. //
  151. //    @Override
  152. //    public synchronized Set<Entry<K, V>> entrySet() {
  153. //        Set<Entry<K, V>> set = new HashSet<>();
  154. //        for (int i = 0; i < map.length; ++i) {
  155. //            set.add(new AbstractMap.SimpleEntry<>(map[i].getKey(), map[i].getValue()));
  156. //        }
  157. //        return set;
  158. //    }
  159. //}
  160.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement