mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-26 05:59:22 +08:00
Refactor Code Style (#4151)
This commit is contained in:
@ -59,9 +59,8 @@ public class Bag<Element> implements Iterable<Element> {
|
||||
* @return true if bag contains element, otherwise false
|
||||
*/
|
||||
public boolean contains(Element element) {
|
||||
Iterator<Element> iterator = this.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next().equals(element)) {
|
||||
for (Element value : this) {
|
||||
if (value.equals(element)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user