mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Made ObjectTable Iterable.
This commit is contained in:
parent
33c2e373d4
commit
221b77a28e
2 changed files with 33 additions and 4 deletions
|
@ -7,15 +7,18 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - Initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.util;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
||||
public abstract class ObjectTable<T> extends HashTable {
|
||||
public abstract class ObjectTable<T> extends HashTable implements Iterable<T> {
|
||||
protected T[] keyTable;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -37,8 +40,8 @@ public abstract class ObjectTable<T> extends HashTable {
|
|||
}
|
||||
|
||||
public List<T> toList() {
|
||||
List<T> list = new ArrayList<T>(size());
|
||||
int size = size();
|
||||
List<T> list = new ArrayList<T>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
list.add(keyAt(i));
|
||||
}
|
||||
|
@ -160,4 +163,30 @@ public abstract class ObjectTable<T> extends HashTable {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.4
|
||||
*/
|
||||
public Iterator<T> iterator() {
|
||||
return new Iterator<T>() {
|
||||
int nextIndex;
|
||||
|
||||
public boolean hasNext() {
|
||||
return nextIndex < size();
|
||||
}
|
||||
|
||||
public T next() {
|
||||
T element = keyAt(nextIndex);
|
||||
if (element == null) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
nextIndex++;
|
||||
return element;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -870,7 +870,7 @@ public class ClassTypeHelper {
|
|||
}
|
||||
|
||||
// Remove overridden methods (even if they are pure virtual)
|
||||
for (ICPPMethod declaredMethod : getOwnMethods(classType).toList()) {
|
||||
for (ICPPMethod declaredMethod : getOwnMethods(classType)) {
|
||||
Set<ICPPMethod> methodsSet = pureVirtualMethods.get(getMethodNameForOverrideKey(declaredMethod));
|
||||
if (methodsSet != null) {
|
||||
for (Iterator<ICPPMethod> methodIt = methodsSet.iterator(); methodIt.hasNext();) {
|
||||
|
|
Loading…
Add table
Reference in a new issue