本文整理汇总了C#中Set类的典型用法代码示例。如果您正苦于以下问题:C# Set类的具体用法?C# Set怎么用?C# Set使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Set类属于命名空间,在下文中一共展示了Set类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Graph_with_one_edge_has_size_1
public void Graph_with_one_edge_has_size_1()
{
var vertices = 1.Upto(2).ToSet();
var edges = new Set<IDirectedEdge<int>> { new DirectedEdge<int>(1, 2) };
var graph = new DirectedGraph<int>(vertices, edges);
graph.Size().ShouldEqual(1);
}
示例2: When_Key_Exists_Append_Succeeds
public void When_Key_Exists_Append_Succeeds()
{
const string key = "Hello";
const string expected = "Hello!";
//clean up old keys
var deleteOperation = new Delete(key, GetVBucket(), Converter, Serializer);
IOStrategy.Execute(deleteOperation);
deleteOperation = new Delete(key + "!", GetVBucket(), Converter, Serializer);
IOStrategy.Execute(deleteOperation);
//create the key
var set = new Set<string>(key, "Hello", GetVBucket(), Converter);
var addResult = IOStrategy.Execute(set);
Assert.IsTrue(addResult.Success);
var append = new Append<string>(key, "!", Serializer, GetVBucket(), Converter);
var result = IOStrategy.Execute(append);
Assert.IsTrue(result.Success);
Assert.AreEqual(string.Empty, result.Value);
var get = new Get<string>(key, GetVBucket(), Converter, Serializer);
var getResult = IOStrategy.Execute(get);
Assert.AreEqual(expected, getResult.Value);
}
示例3: FixRange
// <summary>
// Fixes the range of the restriction in accordance with <paramref name="range" />.
// Member restriction must be complete for this operation.
// </summary>
internal override DomainBoolExpr FixRange(Set<Constant> range, MemberDomainMap memberDomainMap)
{
Debug.Assert(IsComplete, "Ranges are fixed only for complete scalar restrictions.");
var newPossibleValues = memberDomainMap.GetDomain(RestrictedMemberSlot.MemberPath);
BoolLiteral newLiteral = new ScalarRestriction(RestrictedMemberSlot, new Domain(range, newPossibleValues));
return newLiteral.GetDomainBoolExpression(memberDomainMap);
}
示例4: Test_Timed_Execution
public void Test_Timed_Execution()
{
var converter = new DefaultConverter();
var transcoder = new DefaultTranscoder(converter);
var vbucket = GetVBucket();
int n = 1000; //set to a higher # if needed
using (new OperationTimer())
{
var key = string.Format("key{0}", 111);
for (var i = 0; i < n; i++)
{
var set = new Set<int?>(key, 111, vbucket, transcoder, OperationLifespanTimeout);
var get = new Get<int?>(key, vbucket, transcoder, OperationLifespanTimeout);
var result = IOService.Execute(set);
Assert.IsTrue(result.Success);
var result1 = IOService.Execute(get);
Assert.IsTrue(result1.Success);
Assert.AreEqual(111, result1.Value);
}
}
}
示例5: GameDB
public GameDB(params Type[] types)
{
if (types == null || types.Length == 0)
throw new Exception("Need at least one type");
foreach (Type type in types)
entities[type] = new Set<object>();
}
示例6: findClose
/// <summary>
/// This function takes a set of peaks, a lookup mass, and
/// finds the closest peak with in a certain tolerance. If
/// multiple peaks exists with in the window, most closest peak
/// is selected
/// </summary>
/// <param name="peaks">A spectrum</param>
/// <param name="mz">Look up m/z</param>
/// <param name="tolerance">Mass tolerance for look-up</param>
/// <returns>Peak if found</returns>
public static Peak findClose(Set<Peak> peaks, double mz, double tolerance)
{
Set<Peak>.Enumerator cur, min, max;
min = peaks.LowerBound(new Peak(mz - tolerance));
max = peaks.LowerBound(new Peak(mz + tolerance));
if (!min.IsValid && !max.IsValid)
return null;
if (!min.IsValid && max.IsValid)
return max.Current;
if (min.IsValid && !max.IsValid)
return min.Current;
if (min.Current == max.Current)
return null;
// If we found multiple matching peaks,
// return the closest peak.
Peak best = min.Current;
//find the peak closest to the desired mz
double minDiff = Math.Abs(mz - best.mz);
for (cur = min; cur.Current != max.Current; cur.MoveNext())
{
double curDiff = Math.Abs(mz - cur.Current.mz);
if (curDiff < minDiff)
{
minDiff = curDiff;
best = cur.Current;
}
}
return best;
}
示例7: TemplateOptions
public TemplateOptions()
{
Usings = new Set<string>(new[] { "System", "System.IO", "System.Web", "NHaml", "NHaml.Utils", "System.Collections.Generic" });
References = new Set<string>(new[]
{
typeof(TemplateEngine).Assembly.Location, // NHaml
typeof(INotifyPropertyChanged).Assembly.Location, // System
typeof(HttpUtility).Assembly.Location // System.Web
});
AutoClosingTags = new Set<string>(new[] { "META", "IMG", "LINK", "BR", "HR", "INPUT" });
ReferencedTypeHandles = new List<RuntimeTypeHandle>();
MarkupRules = new List<MarkupRule>();
_indentSize = 2;
_templateBaseType = typeof(Template);
_templateCompiler = new CSharp3TemplateCompiler();
TemplateContentProvider = new FileTemplateContentProvider();
AddRule(new EofMarkupRule());
AddRule(new MetaMarkupRule());
AddRule(new DocTypeMarkupRule());
AddRule(new TagMarkupRule());
AddRule(new ClassMarkupRule());
AddRule(new IdMarkupRule());
AddRule(new EvalMarkupRule());
AddRule(new EncodedEvalMarkupRule());
AddRule(new SilentEvalMarkupRule());
AddRule(new PreambleMarkupRule());
AddRule(new CommentMarkupRule());
AddRule(new EscapeMarkupRule());
AddRule(new PartialMarkupRule());
AddRule(new NotEncodedEvalMarkupRule());
}
示例8: SymmetricTest
public void SymmetricTest()
{
var a = new Set<int>(1, 2, 3);
var b = new Set<int>(2, 3, 4);
Console.WriteLine(a.Symmetric(b));
}
示例9: AddSets
public void AddSets()
{
var a = new Set<int>(1, 2, 3, 4, 5);
var b = new Set<int>(6, 7, 8, 9, 10);
Console.WriteLine(a.Add(b).ToString());
}
示例10: IntersectionTest
public void IntersectionTest()
{
var a = new Set<int>(1, 2, 3);
var b = new Set<int>(2, 3, 4);
Console.WriteLine(a.Intersection(b));
}
示例11: TransformSet
/// <summary>
/// Given a Set, produces a CSS property.
/// Implementers can override this method to customize support for CSS properties given a Set.
/// For example if you want a Setter of "Foo" to produce a CSS property "Bar", you can filter it here.
/// You must call this methods for Setter properties you don't wish to filter, so that the default implementation
/// can generate CSS.
/// </summary>
/// <param name="set">The target Set.</param>
/// <returns>The CSS property, in string form.</returns>
public virtual string TransformSet(Set set)
{
// TODO: Some more type checking. I really don't like this entire method.
switch (set.Property.ToLower())
{
case "width":
int widthResult;
if (int.TryParse(set.To, out widthResult))
return string.Format("width: {0}px;", widthResult);
break;
case "height":
int heightResult;
if (int.TryParse(set.To, out heightResult))
return string.Format("height: {0}px;", heightResult);
break;
case "background":
return string.Format("background-color: {0};", set.To);
case "foreground":
return string.Format("color: {0};", set.To);
case "padding":
return string.Format("padding: {0}px;", set.To);
case "margin":
return string.Format("margin: {0}px;", set.To);
}
return string.Empty;
}
示例12: TestDirectedGraphEmptyHasEdgeTrue
public void TestDirectedGraphEmptyHasEdgeTrue()
{
var vertices = 1.Upto(3).ToSet();
var edges = new Set<IDirectedEdge<int>> { new DirectedEdge<int>(1, 2) };
var graph = new DirectedGraph<int>(vertices, edges);
graph.HasEdge(1, 2).ShouldBeTrue();
}
示例13: Graph_with_one_vertex_has_order_1
public void Graph_with_one_vertex_has_order_1()
{
var vertices = 1.WrapInList().ToSet();
var edges = new Set<IDirectedEdge<int>>();
var graph = new DirectedGraph<int>(vertices, edges);
graph.Order().ShouldEqual(1);
}
示例14: AddColumns
public void AddColumns()
{
Column[] columns = new Column[] {
new Column("Name", ColumnType.String),
new Column("Age", ColumnType.Integer)
};
Set set = new Set(columns);
NameValues values = new NameValues();
values.Add("Name", "Adam");
values.Add("Age", 800);
set = set.AddTuple(values);
Column[] newcolumns = new Column[] {
new Column("Height", ColumnType.Integer),
new Column("Weight", ColumnType.Integer)
};
var result = set.AddColumns(newcolumns);
Assert.AreNotEqual(result, set);
Assert.IsNotNull(result.Tuples);
Assert.AreEqual(1, result.Tuples.Count());
Assert.AreEqual(4, result.Columns.Count());
Tuple tuple = result.Tuples.First();
Assert.AreEqual("Adam", tuple[0]);
Assert.AreEqual(800, tuple[1]);
Assert.IsNull(tuple[2]);
Assert.IsNull(tuple[3]);
}
示例15: NameSupply
public NameSupply(IImSet<string> globals, NameSupply parent)
{
this.globals = globals ?? Constants.EmptyStringSet;
boundInThisScope = new Set<string>();
boundInChildScope = new Set<string>();
this.parent = parent;
}