@Override public boolean equals(final Object pOther) { if (pOther == this) { return true; } if (!(pOther instanceof Entry)) { return false; } Entry other = (Entry) pOther; return name.equals(other.name) && (parent == other.parent || (parent != null && parent.equals(other.parent))); }
for (Entry x : entries) { if (x.equals(entryIn)) { return entries.indexOf(x); // if you find it, return the index. } } return -1; // if you didn't return already, you didn't find it. so return -1
LinkedList<Entry> myEntries = new LinkedList<>(); for(Entry entry : myEntries) { if(entry.equals(number) { // logic } }
@Override public boolean equals(final Object pOther) { if (pOther == this) { return true; } if (!(pOther instanceof Entry)) { return false; } Entry other = (Entry) pOther; return name.equals(other.name) && (parent == other.parent || (parent != null && parent.equals(other.parent))); }
@Override public boolean equals(final Object pOther) { if (pOther == this) { return true; } if (!(pOther instanceof Entry)) { return false; } Entry other = (Entry) pOther; return name.equals(other.name) && (mParent == other.mParent || (mParent != null && mParent.equals(other.mParent))); }
HashMap<Object, Object> map = new HashMap<>(); Iterator<Entry<Object, Object>> i = map.entrySet().iterator(); while (i.hasNext()) { Entry next = i.next(); i.remove(); for (Entry e : map.entrySet()) { e.equals(next); } }
final int hashIndex = hashIndex(key); final LinkedList<Entry> entries = table[hashIndex]; //Here entries will be empty on first insert final Iterator<Entry> it = entries.listIterator(); while (it.hasNext()) { // it.hasNext() will returns false, so loop exits without inserting value to the table final Entry entry = it.next(); if (entry.equals(key)) { entry.setValue(value); insertionOrder.add(value); } else { entry.setNext(new Entry(key, value)); insertionOrder.add(value); } }
public void put(Object key, Object value) { int hashIndex = hashIndex(key); LinkedList<Entry> entries = table[hashIndex]; for(Entry entry : entries) { if (entry.equals(key)) { entry.setValue(value); // You might want to update listTail here too return; } } Entry newEntry = new Entry(key, value); entries.add(newEntry); listTail.setNext(newEntry); listTail = newEntry; }
public void put(final Object key, final Object value) { final int hashIndex = hashIndex(key); final LinkedList<Entry> entries = table[hashIndex]; final Iterator<Entry> it = entries.listIterator(); // if (!it.hasNext()) { entries.add(new Entry(key, value)); } else { while (it.hasNext()) { final Entry entry = it.next(); if (entry.equals(key)) { entry.setValue(value); insertionOrder.add(value); } else { entry.setNext(new Entry(key, value)); insertionOrder.add(value); } } } }