let a = []; // Fill the beginning of array to make it keep dense until length exceeds // MAX_DENSE_ELEMENTS_COUNT. for (let i = 0; i < MIN_DENSE; i++)
a[i] = i;
// Skip from MIN_DENSE to MAX_DENSE_ELEMENTS_COUNT - MARGIN, to reduce the // time taken by test.
// Fill the ending of array to make it sparse at MAX_DENSE_ELEMENTS_COUNT. for(let i=MAX_DENSE_ELEMENTS_COUNT -MARGIN i < MAX_DENSE_ELEMENTS_COUNT+MARGIN; i++)
a[i] = i;
// Make sure the last element is defined.
assertEq(a.length, java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 20
/java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
// Make sure elements around MAX_DENSE_ELEMENTS_COUNT are also defined.
assertEq(a[MAX_DENSE_ELEMENTS_COUNT - 1], MAX_DENSE_ELEMENTS_COUNT -1);
assertEq(a[MAX_DENSE_ELEMENTS_COUNT], MAX_DENSE_ELEMENTS_COUNT);
assertEq(a[MAX_DENSE_ELEMENTS_COUNT + 1], MAX_DENSE_ELEMENTS_COUNT a[] = i;
}
// Takes too long time on debug build. if (!getBuildConfiguration("debug")) {
()
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.