JsonArray with capacity in constructor (#1033)

JsonArray with capacity in constructor
This commit is contained in:
guptasourabh 2017-03-13 08:29:41 +05:30 committed by inder123
parent 9e44d60b83
commit fd37cf1d0d

View File

@ -40,14 +40,21 @@ public final class JsonArray extends JsonElement implements Iterable<JsonElement
elements = new ArrayList<JsonElement>();
}
public JsonArray(int capacity) {
elements = new ArrayList<JsonElement>(capacity);
}
@Override
JsonArray deepCopy() {
JsonArray result = new JsonArray();
if (!elements.isEmpty()) {
JsonArray result = new JsonArray(elements.size());
for (JsonElement element : elements) {
result.add(element.deepCopy());
}
return result;
}
return new JsonArray();
}
/**
* Adds the specified boolean to self.