/** * Adds {@code node} to the graph and returns the associated {@link NetworkConnections}. * * @throws IllegalStateException if {@code node} is already present */ @CanIgnoreReturnValue private NetworkConnections<N, E> addNodeInternal(N node) { NetworkConnections<N, E> connections = newConnections(); checkState(nodeConnections.put(node, connections) == null); return connections; }
/** * Adds {@code node} to the graph and returns the associated {@link GraphConnections}. * * @throws IllegalStateException if {@code node} is already present */ @CanIgnoreReturnValue private GraphConnections<N, V> addNodeInternal(N node) { GraphConnections<N, V> connections = newConnections(); checkState(nodeConnections.put(node, connections) == null); return connections; }
/** * Adds {@code node} to the graph and returns the associated {@link NetworkConnections}. * * @throws IllegalStateException if {@code node} is already present */ @CanIgnoreReturnValue private NetworkConnections<N, E> addNodeInternal(N node) { NetworkConnections<N, E> connections = newConnections(); checkState(nodeConnections.put(node, connections) == null); return connections; }
/** * Adds {@code node} to the graph and returns the associated {@link GraphConnections}. * * @throws IllegalStateException if {@code node} is already present */ @CanIgnoreReturnValue private GraphConnections<N, V> addNodeInternal(N node) { GraphConnections<N, V> connections = newConnections(); checkState(nodeConnections.put(node, connections) == null); return connections; }
/** * Adds {@code node} to the graph and returns the associated {@link GraphConnections}. * * @throws IllegalStateException if {@code node} is already present */ @CanIgnoreReturnValue private GraphConnections<N, V> addNodeInternal(N node) { GraphConnections<N, V> connections = newConnections(); checkState(nodeConnections.put(node, connections) == null); return connections; }
/** * Adds {@code node} to the graph and returns the associated {@link NetworkConnections}. * * @throws IllegalStateException if {@code node} is already present */ @CanIgnoreReturnValue private NetworkConnections<N, E> addNodeInternal(N node) { NetworkConnections<N, E> connections = newConnections(); checkState(nodeConnections.put(node, connections) == null); return connections; }
edgeToReferenceNode.put(edge, nodeU); return true;
@Test public void testRemoveEqualKeyWithDifferentReference() { String fooReference1 = new String("foo"); String fooReference2 = new String("foo"); assertThat(fooReference1).isNotSameAs(fooReference2); assertThat(mapCache.put(fooReference1, "bar")).isNull(); assertThat(mapCache.get(fooReference1)).isEqualTo("bar"); // ensure first reference is cached assertThat(mapCache.remove(fooReference2)).isEqualTo("bar"); assertThat(mapCache.get(fooReference1)).isNull(); }
edgeToReferenceNode.put(edge, nodeU); return true;
@Test public void testHandleNulls() { mapCache.put("foo", "bar"); mapCache.put("non-null key", null); mapCache.put(null, "non-null value"); assertThat(mapCache.get("foo")).isEqualTo("bar"); assertThat(mapCache.get("non-null key")).isNull(); assertThat(mapCache.get(null)).isEqualTo("non-null value"); assertThat(mapCache.containsKey("foo")).isTrue(); assertThat(mapCache.containsKey("bar")).isFalse(); assertThat(mapCache.containsKey("non-null key")).isTrue(); assertThat(mapCache.containsKey(null)).isTrue(); // Test again - in reverse order. assertThat(mapCache.get(null)).isEqualTo("non-null value"); assertThat(mapCache.get("non-null key")).isNull(); assertThat(mapCache.get("foo")).isEqualTo("bar"); } }
edgeToReferenceNode.put(edge, nodeU); return true;
/** * Adds {@code node} to the graph and returns the associated {@link GraphConnections}. * * @throws IllegalStateException if {@code node} is already present */ @CanIgnoreReturnValue private GraphConnections<N, V> addNodeInternal(N node) { GraphConnections<N, V> connections = newConnections(); checkState(nodeConnections.put(node, connections) == null); return connections; }
/** * Adds {@code node} to the graph and returns the associated {@link GraphConnections}. * * @throws IllegalStateException if {@code node} is already present */ @CanIgnoreReturnValue private GraphConnections<N, V> addNodeInternal(N node) { GraphConnections<N, V> connections = newConnections(); checkState(nodeConnections.put(node, connections) == null); return connections; }
/** * Adds {@code node} to the graph and returns the associated {@link NetworkConnections}. * * @throws IllegalStateException if {@code node} is already present */ @CanIgnoreReturnValue private NetworkConnections<N, E> addNodeInternal(N node) { NetworkConnections<N, E> connections = newConnections(); checkState(nodeConnections.put(node, connections) == null); return connections; }
/** * Adds {@code node} to the graph and returns the associated {@link NetworkConnections}. * * @throws IllegalStateException if {@code node} is already present */ @CanIgnoreReturnValue private NetworkConnections<N, E> addNodeInternal(N node) { NetworkConnections<N, E> connections = newConnections(); checkState(nodeConnections.put(node, connections) == null); return connections; }
@Test public void testRemoveEqualKeyWithDifferentReference() { String fooReference1 = new String("foo"); String fooReference2 = new String("foo"); assertThat(fooReference1).isNotSameAs(fooReference2); assertThat(mapCache.put(fooReference1, "bar")).isNull(); assertThat(mapCache.get(fooReference1)).isEqualTo("bar"); // ensure first reference is cached assertThat(mapCache.remove(fooReference2)).isEqualTo("bar"); assertThat(mapCache.get(fooReference1)).isNull(); }