本文整理汇总了C#中System.Collections.Set类的典型用法代码示例。如果您正苦于以下问题:C# Set类的具体用法?C# Set怎么用?C# Set使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Set类属于System.Collections命名空间,在下文中一共展示了Set类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SynchronizedSet
/// <summary>
/// Constructs a thread-safe <c>Set</c> wrapper.
/// </summary>
/// <param name="basisSet">The <c>Set</c> object that this object will wrap.</param>
public SynchronizedSet(Set basisSet)
{
_basisSet = basisSet;
_syncRoot = basisSet.SyncRoot;
if(_syncRoot == null)
throw new NullReferenceException("The Set you specified returned a null SyncRoot.");
}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:11,代码来源:SynchronizedSet.cs
示例2: Union
/// <summary>
/// Performs a "union" of the two sets, where all the elements
/// in both sets are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>.
/// Neither this set nor the input set are modified during the operation. The return value
/// is a <c>Clone()</c> of this set with the extra elements added in.
/// </summary>
/// <param name="a">A collection of elements.</param>
/// <returns>A new <c>Set</c> containing the union of this <c>Set</c> with the specified collection.
/// Neither of the input objects is modified by the union.</returns>
public Set Union(Set a)
{
Set resultSet = (Set)this.Clone();
if(a != null)
resultSet.AddAll(a);
return resultSet;
}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:16,代码来源:Set.cs
示例3: Refine
public BinaryDecisionTree Refine(string prop, Set<int> enabledStates)
{
// dont refine already added property
if (this.property.Equals(prop))
return this;
if (states.IsEmpty)
return this;
Set<int> s1 = states.Intersect(enabledStates);
Set<int> s2 = states.Difference(enabledStates);
if (this.trueEdge != null) this.trueEdge.Refine(prop,s1);
if (this.falseEdge != null) this.falseEdge.Refine(prop,s2);
if (this.trueEdge == null && this.falseEdge == null)
{
//if (!s1.IsEmpty)
//{
this.trueEdge = new BinaryDecisionTree(prop, null, null,this.maxValue,this.minValue, s1);
//}
//else this.trueEdge = null;
//if (!s2.IsEmpty)
//{
this.falseEdge = new BinaryDecisionTree(prop, null, null,this.maxValue,this.minValue, s2);
//}
//else this.falseEdge = null;
}
return this;
}
开发者ID:juhan,项目名称:NModel,代码行数:27,代码来源:AbstractMDP.cs
示例4: CometServer
public CometServer()
{
_clients = new Dictionary<string, CometClient>();
_pathIndex = new Dictionary<string, List<CometClient>>();
_usernameIndex = new Dictionary<string, List<CometClient>>();
_requestPaths = new Set<string>();
}
开发者ID:sidecut,项目名称:xaeios,代码行数:7,代码来源:CometServer.cs
示例5: getEdgesBetween
/// <summary>
/// Returns all Edges that connect the two nodes (which are assumed to be different).
/// </summary>
/// <param name="node0"></param>
/// <param name="node1"></param>
/// <returns></returns>
public static IList getEdgesBetween(Node node0, Node node1)
{
IList edges0 = DirectedEdge.ToEdges(node0.OutEdges.Edges);
Set<DirectedEdge> commonEdges = new Set<DirectedEdge>(edges0.Cast<DirectedEdge>());
IList edges1 = DirectedEdge.ToEdges(node1.OutEdges.Edges);
commonEdges.RemoveMany(edges1.Cast<DirectedEdge>());
return new ArrayList(commonEdges);
}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:14,代码来源:Node.cs
示例6: CreateSet
/// <summary>Create the Set just once</summary>
private static void CreateSet()
{
lock(typeof(MessageSequencer))
{
if (msgs != null)
return;
msgs = new Set<int>(s_seqMessages);
}
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:10,代码来源:MessageSequencer.cs
示例7: BinaryDecisionTree
public BinaryDecisionTree(string prop, BinaryDecisionTree t, BinaryDecisionTree f, double maxv, double minv, Set<int> setStates)
{
this.property = prop;
this.trueEdge = t;
this.falseEdge = f;
this.maxValue = maxv;
this.minValue = minv;
this.states = setStates;
}
开发者ID:juhan,项目名称:NModel,代码行数:9,代码来源:AbstractMDP.cs
示例8: UpdateFront
void UpdateFront() {
var newFrontEdges = new Set<CdtEdge>();
foreach (var t in addedTriangles)
foreach (var e in t.Edges)
if (e.CwTriangle == null || e.CcwTriangle == null)
newFrontEdges.Insert(e);
foreach (var e in newFrontEdges)
AddEdgeToFront(e);
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:10,代码来源:EdgeInserter.cs
示例9: Main
static void Main(string[] args)
{
var stackOfValues = new Stack<string>();
GetInitialValuesFromArgs(args, ref stackOfValues);
var demoSet1 = new Set<string>(stackOfValues.ToArray());
Console.WriteLine(demoSet1.ToString());
var demoSet3 = new SortedSet(stackOfValues.ToArray());
Console.WriteLine(demoSet3.ToString());
Console.ReadKey();
}
开发者ID:RavingRabbit,项目名称:Labs,代码行数:10,代码来源:Program.cs
示例10: TestSetDifference
public void TestSetDifference(Set<string> setFirst, Set<string> setSecond, Set<string> resultSet)
{
setFirst.Difference(setSecond);
var iteratorFirst = setFirst.GetEnumerator();
var resultIterator = resultSet.GetEnumerator();
while (iteratorFirst.MoveNext() && resultIterator.MoveNext())
{
Assert.AreEqual(iteratorFirst.Current, resultIterator.Current);
}
}
开发者ID:ZheldakArtem,项目名称:EPAM.Summer.Day10-11.Zheldak,代码行数:10,代码来源:SetTest.cs
示例11: NumberOfActiveNodesIsUnderThreshold
internal static bool NumberOfActiveNodesIsUnderThreshold(List<Edge> inParentEdges, List<Edge> outParentEdges, int threshold) {
var usedNodeSet = new Set<Node>();
foreach (var edge in inParentEdges)
if(SetOfActiveNodesIsLargerThanThreshold((Cluster)edge.Target, edge.Source, usedNodeSet, threshold))
return false;
foreach (var edge in outParentEdges)
if(SetOfActiveNodesIsLargerThanThreshold((Cluster)edge.Source, edge.Target, usedNodeSet, threshold))
return false;
return true;
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:12,代码来源:ShapeCreatorForRoutingToParents.cs
示例12: IsSimple
/// <summary>
/// A MultiPoint is simple if it has no repeated points.
/// </summary>
public bool IsSimple(IMultiPoint mp)
{
if (mp.IsEmpty)
return true;
Set<ICoordinate> points = new Set<ICoordinate>();
for (int i = 0; i < mp.NumGeometries; i++)
{
IPoint pt = (IPoint) mp.GetGeometryN(i);
ICoordinate p = pt.Coordinate;
if (points.Contains(p))
return false;
points.Add(p);
}
return true;
}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:18,代码来源:IsSimpleOp.cs
示例13: SelectAction
/// <summary>
/// Select an action that is enabled in the current state
/// and whose action symbol is in the set <paramref name="actionSymbols"/>.
/// Use coverage points and reward policy.
/// </summary>
/// <param name="actionSymbols">set of candidate action symbols</param>
/// <returns>the chosen action or null if no choice is possible</returns>
public override Action SelectAction(Set<Symbol> actionSymbols)
{
if (actionSymbols == null)
throw new ArgumentNullException("actionSymbols");
if (actionSymbols.IsEmpty)
return null;
Sequence<Action> actions = new Sequence<Action>(this.GetEnabledActions(actionSymbols));
if (actions.IsEmpty)
return null;
Action a = ChooseAction(actions, this.CurrentState); //choose a tester action
//System.Console.WriteLine("Chosen Action " + a.ToString());
return a;
}
开发者ID:juhan,项目名称:NModel,代码行数:23,代码来源:Algorithms.cs
示例14: IntersectionTest
public void IntersectionTest()
{
Set<int> a = new Set<int>();
for(int i = 0; i < 16; i += 2)
a.Add(i);
Set<int> b = new Set<int>();
for(int i = 0; i < 16; i += 3)
b.Add(i);
Set<int> inter = a.Intersect(b);
Assert.AreEqual(3, inter.Count, "A01");
Assert.AreEqual(0, inter[0], "A02");
Assert.AreEqual(6, inter[1], "A03");
Assert.AreEqual(12, inter[2], "A04");
}
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:17,代码来源:SetTest.cs
示例15: minusTest
public void minusTest()
{
Collections.Set<int> s = new Collections.Set<int>();
Collections.Set<int> s2 = new Collections.Set<int>();
int[] a = { 1, 5, 6, 9 };
int[] b = { 1, 4, 7, 9 };
for (int i = 0; i < a.Length; i++)
{
s += (a[i]);
s2 += (b[i]);
}
for (int i = 0; i < a.Length; i++)
{
s -= (a[i]);
s2 -= (b[i]);
}
Assert.AreEqual(0, s.size());
Assert.AreEqual(0, s2.size());
}
开发者ID:sankosk,项目名称:TPP-University-subject-,代码行数:22,代码来源:SetTest.cs
示例16: ConstructionTests
public void ConstructionTests()
{
Set<int> set = new Set<int>();
Assert.AreEqual(0, set.Count, "Set should be empty at first.");
set = new Set<int>(0);
Assert.AreEqual(0, set.Count, "Set should be empty at first.");
set = Set<int>.Empty;
Assert.AreEqual(0, set.Count, "Set should be empty at first.");
int[] ints = new int[] { 1, 2 };
set = new Set<int>(ints);
Assert.AreEqual(2, set.Count, "Set should two itmes in it.");
Set<int> set2 = Create(1, 2);
set = new Set<int>(set2);
Assert.AreEqual(2, set.Count, "Set should two itmes in it.");
set = new Set<int>(set2 as IEnumerable<int>);
Assert.AreEqual(2, set.Count, "Set should two itmes in it.");
}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:22,代码来源:SetTests.cs
示例17: Init
public void Init(FdoCache cache, bool enableCancel)
{
CheckDisposed();
m_cache = cache;
m_btnCancel.Visible = enableCancel;
Set<int> revIdxWs = new Set<int>(4);
foreach (IReversalIndex ri in cache.LangProject.LexDbOA.ReversalIndexesOC)
revIdxWs.Add(ri.WritingSystemRAHvo);
// Include only the analysis writing systems chosen by the user. See LT-7514 and LT-7239.
Set<int> activeWs = new Set<int>(8);
foreach (int ws in cache.LangProject.AnalysisWssRC.HvoArray)
activeWs.Add(ws);
m_cbWritingSystems.Sorted = true;
m_cbWritingSystems.DisplayMember = "Name";
NamedWritingSystem nwsSelected = null;
foreach (NamedWritingSystem nws in cache.LangProject.GetDbNamedWritingSystems())
{
if (revIdxWs.Contains(nws.Hvo))
{
AddLanguageForExistingRevIdx(nws.IcuLocale);
continue;
}
if (!activeWs.Contains(nws.Hvo))
continue;
m_cbWritingSystems.Items.Add(nws);
if (nwsSelected == null && !LanguageMatchesExistingRevIdx(nws.IcuLocale))
nwsSelected = nws;
}
if (nwsSelected != null)
m_cbWritingSystems.SelectedItem = nwsSelected;
if (m_cbWritingSystems.Items.Count > 0 && m_cbWritingSystems.SelectedIndex < 0)
m_cbWritingSystems.SelectedIndex = 0;
if (!enableCancel && m_cbWritingSystems.Items.Count == 0)
throw new ApplicationException("Cancel is disabled, but there are none to choose, so the user has no way to get out of this dialog.");
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:36,代码来源:CreateReversalIndexDlg.cs
示例18: intersectTest
public void intersectTest()
{
Collections.Set<int> s = new Collections.Set<int>();
Collections.Set<int> s2 = new Collections.Set<int>();
int[] a = { 1, 5, 6, 9 };
int[] b = { 1, 4, 7, 9 };
for (int i = 0; i < a.Length; i++)
{
s += (a[i]);
s2 += (b[i]);
}
int[] expected = { 1, 9 };
Collections.Set<int> res = (s & s2);
int[] k = new int[res.size()];
for (int i = 0; i < res.size(); i++) {
k[i] = res.get(i);
}
Array.Sort(k);
CollectionAssert.AreEqual(expected, k);
}
开发者ID:sankosk,项目名称:TPP-University-subject-,代码行数:24,代码来源:SetTest.cs
示例19: FindUnambiguouslyReachableTypes
/// <summary>
/// Determines which types are produced by this mapping.
/// </summary>
private Set<EntityType> FindUnambiguouslyReachableTypes(
DomainConstraintConversionContext<string, ValueCondition> converter, Vertex[] mappingConditions)
{
// For each entity type, create a candidate function that evaluates to true given
// discriminator assignments iff. all of that type's conditions evaluate to true.
var candidateFunctions = new Vertex[MappedEntityTypes.Count];
for (var i = 0; i < candidateFunctions.Length; i++)
{
// Seed the candidate function conjunction with 'true'.
var candidateFunction = Vertex.One;
for (var j = 0; j < NormalizedEntityTypeMappings.Count; j++)
{
var entityTypeMapping = NormalizedEntityTypeMappings[j];
// Determine if this mapping is a positive or negative case for the current type.
if (entityTypeMapping.ImpliedEntityTypes[i])
{
candidateFunction = converter.Solver.And(candidateFunction, mappingConditions[j]);
}
}
candidateFunctions[i] = candidateFunction;
}
// Make sure that for each type with satisfiable candidateFunction all assignments for the type resolve to only that type.
var unambigouslyReachableMap = new BitArray(candidateFunctions.Length, true);
for (var i = 0; i < candidateFunctions.Length; ++i)
{
if (candidateFunctions[i].IsZero())
{
// The i-th type is unreachable regardless of other types.
unambigouslyReachableMap[i] = false;
}
else
{
for (var j = i + 1; j < candidateFunctions.Length; ++j)
{
if (!converter.Solver.And(candidateFunctions[i], candidateFunctions[j]).IsZero())
{
// The i-th and j-th types have common assignments, hence they aren't unambiguously reachable.
unambigouslyReachableMap[i] = false;
unambigouslyReachableMap[j] = false;
}
}
}
}
var reachableTypes = new Set<EntityType>();
for (var i = 0; i < candidateFunctions.Length; ++i)
{
if (unambigouslyReachableMap[i])
{
reachableTypes.Add(MappedEntityTypes[i]);
}
}
return reachableTypes;
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:59,代码来源:FunctionImportStructuralTypeMappingKB.cs
示例20: FindReachableTypes
/// <summary>
/// Determines which types are produced by this mapping.
/// </summary>
private Set<EntityType> FindReachableTypes(
DomainConstraintConversionContext<string, ValueCondition> converter, Vertex[] mappingConditions)
{
// For each entity type, create a candidate function that evaluates to true given
// discriminator assignments iff. all of that type's conditions evaluate to true
// and its negative conditions evaluate to false.
var candidateFunctions = new Vertex[MappedEntityTypes.Count];
for (var i = 0; i < candidateFunctions.Length; i++)
{
// Seed the candidate function conjunction with 'true'.
var candidateFunction = Vertex.One;
for (var j = 0; j < NormalizedEntityTypeMappings.Count; j++)
{
var entityTypeMapping = NormalizedEntityTypeMappings[j];
// Determine if this mapping is a positive or negative case for the current type.
if (entityTypeMapping.ImpliedEntityTypes[i])
{
candidateFunction = converter.Solver.And(candidateFunction, mappingConditions[j]);
}
else
{
candidateFunction = converter.Solver.And(candidateFunction, converter.Solver.Not(mappingConditions[j]));
}
}
candidateFunctions[i] = candidateFunction;
}
// Make sure that for each type there is an assignment that resolves to only that type.
var reachableTypes = new Set<EntityType>();
for (var i = 0; i < candidateFunctions.Length; i++)
{
// Create a function that evaluates to true iff. the current candidate function is true
// and every other candidate function is false.
var isExactlyThisTypeCondition = converter.Solver.And(
candidateFunctions.Select(
(typeCondition, ordinal) => ordinal == i
? typeCondition
: converter.Solver.Not(typeCondition)));
// If the above conjunction is satisfiable, it means some row configuration exists producing the type.
if (!isExactlyThisTypeCondition.IsZero())
{
reachableTypes.Add(MappedEntityTypes[i]);
}
}
return reachableTypes;
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:52,代码来源:FunctionImportStructuralTypeMappingKB.cs
注:本文中的System.Collections.Set类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论