本文整理匯總了Java中com.google.common.collect.Lists.newArrayListWithCapacity方法的典型用法代碼示例。如果您正苦於以下問題:Java Lists.newArrayListWithCapacity方法的具體用法?Java Lists.newArrayListWithCapacity怎麽用?Java Lists.newArrayListWithCapacity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.Lists
的用法示例。
在下文中一共展示了Lists.newArrayListWithCapacity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mergeModelPartVariants
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* Inherits model parts from a parent, creating deep clones of all Variants.
*/
Map<String, List<ForgeBlockStateV1.Variant>> mergeModelPartVariants(Map<String, List<ForgeBlockStateV1.Variant>> output, Map<String, List<ForgeBlockStateV1.Variant>> input)
{
for (Entry<String, List<ForgeBlockStateV1.Variant>> e : input.entrySet())
{
String key = e.getKey();
if (!output.containsKey(key))
{
List<ForgeBlockStateV1.Variant> variants = e.getValue();
if (variants != null)
{
List<ForgeBlockStateV1.Variant> newVariants = Lists.newArrayListWithCapacity(variants.size());
for (ForgeBlockStateV1.Variant v : variants)
newVariants.add(new Variant(v));
output.put(key, newVariants);
}
else
output.put(key, variants);
}
}
return output;
}
示例2: listEncryptionZones
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
public BatchedEntries<EncryptionZone> listEncryptionZones(long id)
throws IOException {
final ListEncryptionZonesRequestProto req =
ListEncryptionZonesRequestProto.newBuilder()
.setId(id)
.build();
try {
EncryptionZonesProtos.ListEncryptionZonesResponseProto response =
rpcProxy.listEncryptionZones(null, req);
List<EncryptionZone> elements =
Lists.newArrayListWithCapacity(response.getZonesCount());
for (EncryptionZoneProto p : response.getZonesList()) {
elements.add(PBHelper.convert(p));
}
return new BatchedListEntries<EncryptionZone>(elements,
response.getHasMore());
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}
}
示例3: cancel
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private void cancel(TccTransaction tccTransaction) {
final List<Participant> participants = tccTransaction.getParticipants();
List<Participant> failList = Lists.newArrayListWithCapacity(participants.size());
boolean success = true;
if (CollectionUtils.isNotEmpty(participants)) {
for (Participant participant : participants) {
try {
TccTransactionContext context = new TccTransactionContext();
context.setAction(TccActionEnum.CANCELING.getCode());
context.setTransId(tccTransaction.getTransId());
TransactionContextLocal.getInstance().set(context);
executeCoordinator(participant.getCancelTccInvocation());
} catch (Exception e) {
LogUtil.error(LOGGER, "執行cancel方法異常:{}", () -> e);
success = false;
failList.add(participant);
}
}
executeHandler(success, tccTransaction, failList);
}
}
示例4: createAclFeature
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* Creates an AclFeature from the given ACL entries.
*
* @param accessEntries List<AclEntry> access ACL entries
* @param defaultEntries List<AclEntry> default ACL entries
* @return AclFeature containing the required ACL entries
*/
private static AclFeature createAclFeature(List<AclEntry> accessEntries,
List<AclEntry> defaultEntries) {
// Pre-allocate list size for the explicit entries stored in the feature,
// which is all entries minus the 3 entries implicitly stored in the
// permission bits.
List<AclEntry> featureEntries = Lists.newArrayListWithCapacity(
(accessEntries.size() - 3) + defaultEntries.size());
// For the access ACL, the feature only needs to hold the named user and
// group entries. For a correctly sorted ACL, these will be in a
// predictable range.
if (!AclUtil.isMinimalAcl(accessEntries)) {
featureEntries.addAll(
accessEntries.subList(1, accessEntries.size() - 2));
}
// Add all default entries to the feature.
featureEntries.addAll(defaultEntries);
return new AclFeature(AclEntryStatusFormat.toInt(featureEntries));
}
示例5: setXAttr
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* Set xattr for a file or directory.
*
* @param src
* - path on which it sets the xattr
* @param xAttr
* - xAttr details to set
* @param flag
* - xAttrs flags
* @throws IOException
*/
static HdfsFileStatus setXAttr(
FSDirectory fsd, String src, XAttr xAttr, EnumSet<XAttrSetFlag> flag,
boolean logRetryCache)
throws IOException {
checkXAttrsConfigFlag(fsd);
checkXAttrSize(fsd, xAttr);
FSPermissionChecker pc = fsd.getPermissionChecker();
XAttrPermissionFilter.checkPermissionForApi(
pc, xAttr, FSDirectory.isReservedRawName(src));
byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
src = fsd.resolvePath(pc, src, pathComponents);
List<XAttr> xAttrs = Lists.newArrayListWithCapacity(1);
xAttrs.add(xAttr);
INodesInPath iip;
fsd.writeLock();
try {
iip = fsd.getINodesInPath4Write(src);
checkXAttrChangeAccess(fsd, iip, xAttr, pc);
unprotectedSetXAttrs(fsd, src, xAttrs, flag);
} finally {
fsd.writeUnlock();
}
fsd.getEditLog().logSetXAttrs(src, xAttrs, logRetryCache);
return fsd.getAuditFileInfo(iip);
}
示例6: setUp
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@BeforeExperiment void setUp() {
random = new Random(0xdeadbeef); // fix the seed so results are comparable across runs
int nonAlpha = size / nonAlphaRatio;
int alpha = size - nonAlpha;
List<Character> chars = Lists.newArrayListWithCapacity(size);
for (int i = 0; i < alpha; i++) {
chars.add(randomAlpha());
}
for (int i = 0; i < nonAlpha; i++) {
chars.add(randomNonAlpha());
}
Collections.shuffle(chars, random);
char[] array = Chars.toArray(chars);
this.testString = new String(array);
}
示例7: setFileEncryptionInfo
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* Set the FileEncryptionInfo for an INode.
*/
void setFileEncryptionInfo(String src, FileEncryptionInfo info)
throws IOException {
// Make the PB for the xattr
final HdfsProtos.PerFileEncryptionInfoProto proto =
PBHelper.convertPerFileEncInfo(info);
final byte[] protoBytes = proto.toByteArray();
final XAttr fileEncryptionAttr =
XAttrHelper.buildXAttr(CRYPTO_XATTR_FILE_ENCRYPTION_INFO, protoBytes);
final List<XAttr> xAttrs = Lists.newArrayListWithCapacity(1);
xAttrs.add(fileEncryptionAttr);
writeLock();
try {
FSDirXAttrOp.unprotectedSetXAttrs(this, src, xAttrs,
EnumSet.of(XAttrSetFlag.CREATE));
} finally {
writeUnlock();
}
}
示例8: splitPath
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private static String[] splitPath(String path) {
// Let's make sure we never need to reallocate
List<String> components = Lists.newArrayListWithCapacity(path.length());
StringTokenizer tokenizer = new StringTokenizer(path, ".");
while (tokenizer.hasMoreTokens()) {
String component = tokenizer.nextToken();
if (component.isEmpty()) {
continue;
}
components.add(component);
}
return components.toArray(new String[components.size()]);
}
示例9: Builder
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private Builder(boolean p_i46076_1_, boolean p_i46076_2_, ItemCameraTransforms p_i46076_3_)
{
this.builderGeneralQuads = Lists.<BakedQuad>newArrayList();
this.builderFaceQuads = Lists.<List<BakedQuad>>newArrayListWithCapacity(6);
for (EnumFacing enumfacing : EnumFacing.values())
{
this.builderFaceQuads.add(Lists.<BakedQuad>newArrayList());
}
this.builderAmbientOcclusion = p_i46076_1_;
this.builderGui3d = p_i46076_2_;
this.builderCameraTransforms = p_i46076_3_;
}
示例10: generateXAttrs
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private static List<XAttr> generateXAttrs(final int numXAttrs) {
List<XAttr> generatedXAttrs = Lists.newArrayListWithCapacity(numXAttrs);
for (int i=0; i<numXAttrs; i++) {
XAttr xAttr = (new XAttr.Builder())
.setNameSpace(XAttr.NameSpace.SYSTEM)
.setName("a" + i)
.setValue(new byte[] { (byte) i, (byte) (i + 1), (byte) (i + 2) })
.build();
generatedXAttrs.add(xAttr);
}
return generatedXAttrs;
}
示例11: getServers
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private List<ServerInfo> getServers(Collection<ServiceInstance<MetaInfo>> servers) {
if(servers == null || servers.isEmpty()){
return null;
}
List<ServerInfo> res = Lists.newArrayListWithCapacity(servers.size());
for(ServiceInstance<MetaInfo> inst: servers){
res.add(new ServerInfo(inst));
}
return res;
}
示例12: removeXAttr
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* Remove an xattr for a file or directory.
*
* @param src
* - path to remove the xattr from
* @param xAttr
* - xAttr to remove
* @throws IOException
*/
static HdfsFileStatus removeXAttr(
FSDirectory fsd, String src, XAttr xAttr, boolean logRetryCache)
throws IOException {
FSDirXAttrOp.checkXAttrsConfigFlag(fsd);
FSPermissionChecker pc = fsd.getPermissionChecker();
XAttrPermissionFilter.checkPermissionForApi(
pc, xAttr, FSDirectory.isReservedRawName(src));
byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(
src);
List<XAttr> xAttrs = Lists.newArrayListWithCapacity(1);
xAttrs.add(xAttr);
INodesInPath iip;
fsd.writeLock();
try {
src = fsd.resolvePath(pc, src, pathComponents);
iip = fsd.getINodesInPath4Write(src);
checkXAttrChangeAccess(fsd, iip, xAttr, pc);
List<XAttr> removedXAttrs = unprotectedRemoveXAttrs(fsd, src, xAttrs);
if (removedXAttrs != null && !removedXAttrs.isEmpty()) {
fsd.getEditLog().logRemoveXAttrs(src, removedXAttrs, logRetryCache);
} else {
throw new IOException(
"No matching attributes found for remove operation");
}
} finally {
fsd.writeUnlock();
}
return fsd.getAuditFileInfo(iip);
}
示例13: read
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
public PluginRequests read(Decoder decoder) throws Exception {
int requestCount = decoder.readSmallInt();
List<PluginRequest> requests = Lists.newArrayListWithCapacity(requestCount);
for (int i = 0; i < requestCount; i++) {
PluginId pluginId = PluginId.unvalidated(decoder.readString());
String version = decoder.readNullableString();
boolean apply = decoder.readBoolean();
int lineNumber = decoder.readSmallInt();
String scriptDisplayName = decoder.readString();
requests.add(i, new DefaultPluginRequest(pluginId, version, apply, lineNumber, scriptDisplayName));
}
return new DefaultPluginRequests(requests);
}
示例14: CollectionFutureRunningState
import com.google.common.collect.Lists; //導入方法依賴的package包/類
CollectionFutureRunningState(
ImmutableCollection<? extends ListenableFuture<? extends V>> futures,
boolean allMustSucceed) {
super(futures, allMustSucceed, true);
this.values =
futures.isEmpty()
? ImmutableList.<Optional<V>>of()
: Lists.<Optional<V>>newArrayListWithCapacity(futures.size());
// Populate the results list with null initially.
for (int i = 0; i < futures.size(); ++i) {
values.add(null);
}
}
示例15: getResult
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* 穿成串
*/
@SuppressWarnings({ "rawtypes" })
@Override
public List<Map> getResult(boolean isNeed) {
List<Map> list = Lists.newArrayListWithCapacity(1);
if (isNeed && stacktracelogs.length() > 0) {
list.add(ImmutableMap.of(INDEX, stacktracelogs.toString()));
stacktracelogs.setLength(0);
}
return list;
}