本文整理匯總了C#中AList.TrimToSize方法的典型用法代碼示例。如果您正苦於以下問題:C# AList.TrimToSize方法的具體用法?C# AList.TrimToSize怎麽用?C# AList.TrimToSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AList
的用法示例。
在下文中一共展示了AList.TrimToSize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ScanCachedPacks
/// <exception cref="System.IO.IOException"></exception>
private ObjectDirectory.CachedPackList ScanCachedPacks(ObjectDirectory.CachedPackList
old)
{
FileSnapshot s = FileSnapshot.Save(cachedPacksFile);
byte[] buf;
try
{
buf = IOUtil.ReadFully(cachedPacksFile);
}
catch (FileNotFoundException)
{
buf = new byte[0];
}
if (old != null && old.snapshot.Equals(s) && Arrays.Equals(old.raw, buf))
{
old.snapshot.SetClean(s);
return old;
}
AList<LocalCachedPack> list = new AList<LocalCachedPack>(4);
ICollection<ObjectId> tips = new HashSet<ObjectId>();
int ptr = 0;
while (ptr < buf.Length)
{
if (buf[ptr] == '#' || buf[ptr] == '\n')
{
ptr = RawParseUtils.NextLF(buf, ptr);
continue;
}
if (buf[ptr] == '+')
{
tips.AddItem(ObjectId.FromString(buf, ptr + 2));
ptr = RawParseUtils.NextLF(buf, ptr + 2);
continue;
}
IList<string> names = new AList<string>(4);
while (ptr < buf.Length && buf[ptr] == 'P')
{
int end = RawParseUtils.NextLF(buf, ptr);
if (buf[end - 1] == '\n')
{
end--;
}
names.AddItem(RawParseUtils.Decode(buf, ptr + 2, end));
ptr = RawParseUtils.NextLF(buf, end);
}
if (!tips.IsEmpty() && !names.IsEmpty())
{
list.AddItem(new LocalCachedPack(this, tips, names));
tips = new HashSet<ObjectId>();
}
}
list.TrimToSize();
return new ObjectDirectory.CachedPackList(s, Sharpen.Collections.UnmodifiableList
(list), buf);
}