11/*
2- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
3030import java .util .Iterator ;
3131import java .util .LinkedList ;
3232import java .util .Map ;
33- import java .util .Set ;
3433
3534/**
3635 * A set of {@code Object}s with pairwise orderings between them.
@@ -58,22 +57,19 @@ class PartiallyOrderedSet<E> extends AbstractSet<E> {
5857 // p. 315.
5958
6059 // Maps Objects to DigraphNodes that contain them
61- private Map <E , DigraphNode <E >> poNodes = new HashMap <>();
62-
63- // The set of Objects
64- private Set <E > nodes = poNodes .keySet ();
60+ private final Map <E , DigraphNode <E >> poNodes = new HashMap <>();
6561
6662 /**
6763 * Constructs a {@code PartiallyOrderedSet}.
6864 */
6965 public PartiallyOrderedSet () {}
7066
7167 public int size () {
72- return nodes .size ();
68+ return poNodes .size ();
7369 }
7470
7571 public boolean contains (Object o ) {
76- return nodes . contains (o );
72+ return poNodes . containsKey (o );
7773 }
7874
7975 /**
@@ -90,7 +86,7 @@ public Iterator<E> iterator() {
9086 * {@code PartiallyOrderedSet}.
9187 */
9288 public boolean add (E o ) {
93- if (nodes . contains (o )) {
89+ if (poNodes . containsKey (o )) {
9490 return false ;
9591 }
9692
0 commit comments