Compute list size.

@param order field order
@param list field value
@param type field type of list obj
@param debug the debug
@param path the path
@return full java expression
493516
public static int computeListSize(int order, List<?> list, FieldType type, boolean debug, File path) {
        return computeListSize(order, list, type, debug, path, false, false);
    }
189874
@Override
  public String []list(String path) throws IOException
  {
    if (path.startsWith("/")) {
      path = path.substring(1);
    }
    
    if (! path.endsWith("/")) {
      path = path + "/";
    }

    ArrayList<String> names = new ArrayList<>();
    
    try (ZipInputStream zIn = new ZipInputStream(getBacking().openRead())) {
      ZipEntry entry;
      
      while ((entry = zIn.getNextEntry()) != null) {
        String name = entry.getName();

        if (name.startsWith(path)) {
          String tail = name.substring(path.length());
          int p = tail.indexOf('/');
          
          if (p >= 0) {
            tail = tail.substring(0, p);
          }
          
          if (! tail.equals("") && ! names.contains(tail)) {
            names.add(tail);
          }
        }
      }
    }
    
    String []list = new String[names.size()];
    
    names.toArray(list);
    
    return list;
  }
22017
static SortedRangeSet of(Type type, Object first, Object... rest)
    {
        List<Range> ranges = new ArrayList<>(rest.length + 1);
        ranges.add(Range.equal(type, first));
        for (Object value : rest) {
            ranges.add(Range.equal(type, value));
        }
        return copyOf(type, ranges);
    }
858387
public static List<Object[]> getFieldDebugInfos(final String field, String clientId)
    {
        Map<String, List<Object[]>> debugInfo = getDebugInfoMap(clientId);
        List<Object[]> fieldDebugInfo = debugInfo.get(field);
        if (fieldDebugInfo == null)
        {
            // no field debug-infos yet, create them and store it in the Map
            fieldDebugInfo = new ArrayList<Object[]>();
            debugInfo.put(field, fieldDebugInfo);
        }
        return fieldDebugInfo;
    }
801042
private List<Object[]> _getFieldDebugInfos(final String field)
    {
        Map<String, List<Object[]>> debugInfo = _getDebugInfoMap();
        List<Object[]> fieldDebugInfo = debugInfo.get(field);
        if (fieldDebugInfo == null)
        {
            // no field debug-infos yet, create them and store it in the Map
            fieldDebugInfo = new ArrayList<Object[]>();
            debugInfo.put(field, fieldDebugInfo);
        }
        return fieldDebugInfo;
    }
760994
public <A, E extends SimpleExpression<A>> ListPath<A, E> getList(String property, Class<A> type, Class<? super E> queryType) {
        validate(property, List.class);
        return super.createList(property, type, queryType, PathInits.DIRECT);
    }
1076154
public static String getMappedTypeDefined(int order, FieldType type, String express, boolean isList) {

        String fieldName = getFieldName(order);
        if ((type == FieldType.STRING || type == FieldType.BYTES) && !isList) {
            // add null check
            String code = "com.google.protobuf.ByteString " + fieldName + "=null" + ClassCode.JAVA_LINE_BREAK;
            code += "if (!CodedConstant.isNull(" + express + ")) {\n";

            String method = "copyFromUtf8";
            if (type == FieldType.BYTES) {
                method = "copyFrom";
            }

            code += fieldName + " = com.google.protobuf.ByteString." + method + "(" + express + ")"
                    + ClassCode.JAVA_LINE_BREAK;
            code += "}";
            return code;
        }
        // add null check
        String defineType = type.getJavaType();
        if (isList) {
            defineType = "List";
        }

        String code = defineType + " " + fieldName + "=null" + ClassCode.JAVA_LINE_BREAK;
        code += "if (!CodedConstant.isNull(" + express + ")) {\n";

        code += fieldName + "=" + express + ClassCode.JAVA_LINE_BREAK;
        code += "}";
        return code;
    }
171640
public int getListFieldLength(String fieldName) {
		int ret = -1;
		Object val = getFieldValue(fieldName, true); // internal
		if (val instanceof List<?>)
			ret = ((List<?>)val).size();
		else if (val != null && val.getClass().isArray()) {
			ret = Array.getLength(val);
		} else {
			if (!getDomainObjectType().getFieldByName(fieldName).isListOrArray())
				throw new RuntimeException("field: [" + fieldName + "] is neither list nor array");
			if (val == null)
				throw new RuntimeException("list or array field: [" + fieldName + "] is null");
		}
		return ret;
	}
1253161
@Deprecated public static int size (Object[] list)
    {
        if (list == null) {
            return 0;
        }
        int llength = list.length;
        for (int ii = 0; ii < llength; ii++) {
            if (list[ii] == null) {
                return ii;
            }
        }
        return llength;
    }
632768
static <T> int listSizeInBytes(Buffer.Writer<T> writer, List<T> values) {
    int sizeInBytes = 5;
    for (int i = 0, length = values.size(); i < length; i++) {
      sizeInBytes += writer.sizeInBytes(values.get(i));
    }
    return sizeInBytes;
  }
218276
public static double computeLength(List<IGeoPoint> path) {
        if (path.size() < 2) {
            return 0;
        }
        double length = 0;
        IGeoPoint prev = path.get(0);
        double prevLat = toRadians(prev.getLatitude());
        double prevLng = toRadians(prev.getLongitude());
        for (IGeoPoint point : path) {
            double lat = toRadians(point.getLatitude());
            double lng = toRadians(point.getLongitude());
            length += distanceRadians(prevLat, prevLng, lat, lng);
            prevLat = lat;
            prevLng = lng;
        }
        return length * EARTH_RADIUS;
    }
1086627
private <T extends Index> List<T> listIndexType(String type, Class<T> modelType) {
        List<T> indexesOfType = new ArrayList<T>();
        Gson g = new Gson();
        for (JsonElement index : indexes) {
            if (index.isJsonObject()) {
                JsonObject indexDefinition = index.getAsJsonObject();
                JsonElement indexType = indexDefinition.get("type");
                if (indexType != null && indexType.isJsonPrimitive()) {
                    JsonPrimitive indexTypePrimitive = indexType.getAsJsonPrimitive();
                    if (type == null || (indexTypePrimitive.isString() && indexTypePrimitive
                            .getAsString().equals(type))) {
                        indexesOfType.add(g.fromJson(indexDefinition, modelType));
                    }
                }
            }
        }
        return indexesOfType;
    }
594307
Integer getDatabasePageSize(Class<? extends Storable> type) {
        if (mDatabasePageSizes == null) {
            return null;
        }
        Integer size = mDatabasePageSizes.get(type);
        if (size == null && type != null) {
            size = mDatabasePageSizes.get(null);
        }
        return size;
    }
795352
public void listQueryImpl(String path,
                            Result<List<String>> result)
  {
    _dirList.findAll(result.then(cursorIter->listResult(cursorIter, path)), 
                     calculateParentHash(path), path);
  }
330695
public List<String> getMultiSelect(String path) {
        List<String> values = new ArrayList<String>();
        for (JsonValue val : this.getValue(path).asArray()) {
            values.add(val.asString());
        }

        return values;
    }
344875
private static int computeFieldSize(AttributeValue value) throws DBaseFileException, AttributeException {
		final DBaseFieldType dbftype = DBaseFieldType.fromAttributeType(value.getType());
		return dbftype.getFieldSize(value.getString());
	}
306181
public static <T extends Comparable<? super T>> void sort(List<T> list) {
		sort(list, QuickSort.<T>naturalOrder()); // JAVA_8 replace with Comparator.naturalOrder() (and cleanup)   
	}