/** * Converts this cursor to an array. * * @param max the maximum number of objects to return * @return an array of objects * @throws MongoException */ public List<DBObject> toArray(int max) throws MongoException { _checkType(CursorType.ARRAY); _fill(max - 1); return _all; }
/** * pulls back all items into an array and returns the number of objects. Note: this can be * resource intensive * * @see #count() * @see #size() * @return the number of elements in the array * @throws MongoException */ public int length() throws MongoException { _checkType(CursorType.ARRAY); _fill(Integer.MAX_VALUE); return _all.size(); }