| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public int compareTo(OrcMap<K,V> other) { |
| 89 | if (other == null) { |
| 90 | return -1; |
| 91 | } |
| 92 | int result = keySchema.compareTo(other.keySchema); |
| 93 | if (result != 0) { |
| 94 | return result; |
| 95 | } |
| 96 | result = valueSchema.compareTo(other.valueSchema); |
| 97 | if (result != 0) { |
| 98 | return result; |
| 99 | } |
| 100 | Iterator<Map.Entry<K,V>> ourItr = entrySet().iterator(); |
| 101 | Iterator<Map.Entry<K,V>> theirItr = other.entrySet().iterator(); |
| 102 | while (ourItr.hasNext() && theirItr.hasNext()) { |
| 103 | Map.Entry<K,V> ourItem = ourItr.next(); |
| 104 | Map.Entry<K,V> theirItem = theirItr.next(); |
| 105 | K ourKey = ourItem.getKey(); |
| 106 | K theirKey = theirItem.getKey(); |
| 107 | int val = ourKey.compareTo(theirKey); |
| 108 | if (val != 0) { |
| 109 | return val; |
| 110 | } |
| 111 | Comparable<V> ourValue = ourItem.getValue(); |
| 112 | V theirValue = theirItem.getValue(); |
| 113 | if (ourValue == null) { |
| 114 | if (theirValue != null) { |
| 115 | return 1; |
| 116 | } |
| 117 | } else if (theirValue == null) { |
| 118 | return -1; |
| 119 | } else { |
| 120 | val = ourItem.getValue().compareTo(theirItem.getValue()); |
| 121 | if (val != 0) { |
| 122 | return val; |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | if (ourItr.hasNext()) { |
| 127 | return 1; |
| 128 | } else if (theirItr.hasNext()) { |
| 129 | return -1; |
| 130 | } else { |
| 131 | return 0; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | @Override |
| 136 | public boolean equals(Object other) { |