本文整理汇总了C#中HashSet.IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# HashSet.IsEmpty方法的具体用法?C# HashSet.IsEmpty怎么用?C# HashSet.IsEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashSet
的用法示例。
在下文中一共展示了HashSet.IsEmpty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContainsAnyImplementation
private static bool ContainsAnyImplementation(string source, IEnumerable<char> characters)
{
Debug.Assert(source != null, "source != null");
Debug.Assert(characters != null, "characters != null");
var hs = new HashSet<char>(characters);
return !hs.IsEmpty() && source.Any(hs.Contains);
}
示例2: RemoveSyntaxTrees
/// <summary>
/// Creates a new compilation without the specified syntax trees. Preserves metadata info for use with trees
/// added later.
/// </summary>
public new CSharpCompilation RemoveSyntaxTrees(IEnumerable<SyntaxTree> trees)
{
using (Logger.LogBlock(FunctionId.CSharp_Compilation_RemoveSyntaxTrees, message: this.AssemblyName))
{
if (trees == null)
{
throw new ArgumentNullException("trees");
}
if (trees.IsEmpty())
{
return this;
}
bool referenceDirectivesChanged = false;
var removeSet = new HashSet<SyntaxTree>();
var declMap = rootNamespaces;
var declTable = declarationTable;
foreach (var tree in trees.Cast<CSharpSyntaxTree>())
{
RemoveSyntaxTreeFromDeclarationMapAndTable(tree, ref declMap, ref declTable, ref referenceDirectivesChanged);
removeSet.Add(tree);
}
Debug.Assert(!removeSet.IsEmpty());
// We're going to have to revise the ordinals of all
// trees after the first one removed, so just build
// a new map.
var ordinalMap = ImmutableDictionary.Create<SyntaxTree, int>();
var builder = ArrayBuilder<SyntaxTree>.GetInstance();
int i = 0;
foreach (var tree in this.SyntaxTrees)
{
if (!removeSet.Contains(tree))
{
builder.Add(tree);
ordinalMap = ordinalMap.Add(tree, i++);
}
}
return UpdateSyntaxTrees(builder.ToImmutableAndFree(), ordinalMap, declMap, declTable, referenceDirectivesChanged);
}
}
示例3: 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);
}
示例4: RecvWants
/// <exception cref="System.IO.IOException"></exception>
private void RecvWants()
{
HashSet<ObjectId> wantIds = new HashSet<ObjectId>();
bool isFirst = true;
for (; ; )
{
string line;
try
{
line = pckIn.ReadString();
}
catch (EOFException eof)
{
if (isFirst)
{
break;
}
throw;
}
if (line == PacketLineIn.END)
{
break;
}
if (!line.StartsWith("want ") || line.Length < 45)
{
throw new PackProtocolException(MessageFormat.Format(JGitText.Get().expectedGot,
"want", line));
}
if (isFirst && line.Length > 45)
{
string opt = Sharpen.Runtime.Substring(line, 45);
if (opt.StartsWith(" "))
{
opt = Sharpen.Runtime.Substring(opt, 1);
}
foreach (string c in opt.Split(" "))
{
options.AddItem(c);
}
line = Sharpen.Runtime.Substring(line, 0, 45);
}
wantIds.AddItem(ObjectId.FromString(Sharpen.Runtime.Substring(line, 5)));
isFirst = false;
}
if (wantIds.IsEmpty())
{
return;
}
AsyncRevObjectQueue q = walk.ParseAny(wantIds.AsIterable (), true);
try
{
for (; ; )
{
RevObject o;
try
{
o = q.Next();
}
catch (IOException error)
{
throw new PackProtocolException(MessageFormat.Format(JGitText.Get().notValid, error
.Message), error);
}
if (o == null)
{
break;
}
if (o.Has(WANT))
{
}
else
{
// Already processed, the client repeated itself.
if (o.Has(ADVERTISED))
{
o.Add(WANT);
wantAll.AddItem(o);
if (o is RevTag)
{
o = walk.Peel(o);
if (o is RevCommit)
{
if (!o.Has(WANT))
{
o.Add(WANT);
wantAll.AddItem(o);
}
}
}
}
else
{
throw new PackProtocolException(MessageFormat.Format(JGitText.Get().notValid, o.Name
));
}
}
}
}
finally
//.........这里部分代码省略.........
示例5: getFuturesStatic
//.........这里部分代码省略.........
// Get Static From cache here if we have it, tickersplittuple has been set.
Frame<string, string> cachedValue;
if (StaticCache_.TryGetValue(cacheKey, out cachedValue)) return cachedValue;
// Get all the roots from list
List< string> rollingFuturesIDs = new List<string>();
foreach (var tup in rootTickers)
{
rollingFuturesIDs.Add(tup.Item1);
}
// Get test sets.
// This allows us to map back names used in futures static moniker, to our original inputs
var bbgTickerMap = processBBGTickerList(contractTickers);
HashSet<string> rollingSet = new HashSet<string>(rollingFuturesIDs);
HashSet<string> tickerSet = new HashSet<string>(bbgTickerMap.Keys.AsEnumerable());
// Processing inputs
Frame<string, string> output;
var rowList = new List<KeyValuePair<int/*id*/, Series<string, object>/*row*/>>();
var df = client.GetDataFrame(futuresStaticMoniker);
var tmp = df.ToList();
var col = tmp[0].Value as List<object>;
var ind = tmp[1].Value as List<object>;
var dat = tmp[2].Value as List<object>;
//Find it's first trade date col
int firstTradeDtCol = 0;
int futDeliveryDtCol = 0;
int typeCol = 0;
for (int j = 0; j < col.Count; ++j)
{
string heading = col[j].ToString();
if (heading == "fut_first_trade_dt")
{
firstTradeDtCol = j;
}
if (heading == "fut_dlv_dt_last")
{
futDeliveryDtCol = j;
}
if(heading == "type")
{
typeCol = j;
}
}
//client.getdat
SeriesBuilder<string> sb;
int i;
for (i = 0; i < ind.Count; ++i)
{
sb = new SeriesBuilder<string>();
var data = dat[i] as List<object>;
var contract = data[typeCol].ToString();
string index = (string)ind[i];
if ((tickerSet.IsEmpty() && rollingSet.IsEmpty())
|| (!tickerSet.Contains(index) && !rollingSet.Contains(contract)))
{
continue;
}
DateTime firstTradeDate = DateTime.ParseExact(data[firstTradeDtCol].ToString(), "%dd/%MM/%yyyy", CultureInfo.InvariantCulture);
DateTime futDeliveryDate = DateTime.ParseExact(data[futDeliveryDtCol].ToString(), "%dd/%MM/%yyyy", CultureInfo.InvariantCulture);
if (rollingSet.Contains(contract) && (futDeliveryDate < startDate || firstTradeDate > endDate))
{
continue;
}
if (bbgTickerMap.ContainsKey(index))
sb.Add("ticker", bbgTickerMap[index]);
else
sb.Add("ticker", index); // ignores the mappings, in the rolling contract case
for (int h = 0; h < col.Count; ++h)
{
sb.Add((string)col[h], data[h]);
}
rowList.Add(KeyValue.Create(i, sb.Series));
}
output = Frame.FromRows(rowList).IndexRows<string>("ticker", keepColumn: true);
if (rootTickers.IsEmpty())
{
output = sortFrameByInput(output, tickers);
}
else
{
output = sortFrameByNaturalOrder(output, contractSortOrder);
}
StaticCache_.TryAdd(cacheKey, output.Clone());
return output;
}
示例6: Expand
//.........这里部分代码省略.........
}
}
}
else
{
// 7.11)
// 7.11.1)
if (!result.ContainsKey(expandedProperty))
{
result[expandedProperty] = new JArray();
}
// 7.11.2)
if (expandedValue is JArray)
{
JsonLD.Collections.AddAll(((JArray)result[expandedProperty]), (JArray)expandedValue);
}
else
{
((JArray)result[expandedProperty]).Add(expandedValue);
}
}
}
// 8)
if (result.ContainsKey("@value"))
{
// 8.1)
// TODO: is this method faster than just using containsKey for
// each?
ICollection<string> keySet = new HashSet<string>(result.GetKeys());
keySet.Remove("@value");
keySet.Remove("@index");
bool langremoved = keySet.Remove("@language");
bool typeremoved = keySet.Remove("@type");
if ((langremoved && typeremoved) || !keySet.IsEmpty())
{
throw new JsonLdError(JsonLdError.Error.InvalidValueObject, "value object has unknown keys"
);
}
// 8.2)
JToken rval = result["@value"];
if (rval.IsNull())
{
// nothing else is possible with result if we set it to
// null, so simply return it
return null;
}
// 8.3)
if (!(rval.Type == JTokenType.String) && result.ContainsKey("@language"))
{
throw new JsonLdError(JsonLdError.Error.InvalidLanguageTaggedValue, "when @language is used, @value must be a string"
);
}
else
{
// 8.4)
if (result.ContainsKey("@type"))
{
// TODO: is this enough for "is an IRI"
if (!(result["@type"].Type == JTokenType.String) || ((string)result["@type"]).StartsWith("_:") ||
!((string)result["@type"]).Contains(":"))
{
throw new JsonLdError(JsonLdError.Error.InvalidTypedValue, "value of @type must be an IRI"
);
}
}
}