aureooms/js-convex-hull-2d

View on GitHub
js/src/0-core/lib/array/argmax.js

Summary

Maintainability
B
4 hrs
Test Coverage
const argmax = function ( compare, a, i, j ) {

    var k, key, tmp;

    if ( i >= j ) return undefined ;

    k = i;
    key = a[k];

    for ( ++i ; i < j ; ++i ) {

        tmp = a[i];

        if ( compare( tmp, key ) > 0 ) {
            k = i;
            key = tmp;
        }

    }

    return k;
} ;