1

Thema: contains

http://ix.io/5l/java

moep :)

Zuletzt bearbeitet von Nils (21.07.2009 23:05:58)

2

Re: contains

// ist Element vorhanden?
    public boolean contains(X x) {
        int i = 0;
        boolean found = false;
        while(!found && (i < this.filled)) {
            found = this.comparator.same(this.elements[i], x);
            ++i;
        }            
        return found;
    }

und dann im

IComparator<X>

public boolean same(X x1, X x2);

und
in IntegerComparator

public boolean same(Integer x1, Integer x2) {
        return x1 == x2;
    }

sieht irgendwie schöner aus ;)
naja, dafür benutze ich aber nicht das tolle Bisektionsverfahren...

Zuletzt bearbeitet von Seppo (21.07.2009 20:45:48)

3

Re: contains

@Seppo
lol!

Zuletzt bearbeitet von Julian (24.07.2009 01:38:17)

4

Re: contains

Warum hast du deinen Code so verkompliziert?

Julian