本文整理汇总了C#中Set.Union方法的典型用法代码示例。如果您正苦于以下问题:C# Set.Union方法的具体用法?C# Set.Union怎么用?C# Set.Union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set.Union方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
var setOne = new Set<int>();
setOne.Add(5);
setOne.Add(5);
setOne.Add(5);
setOne.Add(5);
setOne.Add(5);
setOne.Add(5);
setOne.Add(5);
setOne.Add(5);
setOne.Add(5);
setOne.Add(6);
var setTwo = new Set<int>();
setTwo.Add(5);
setTwo.Add(10);
Console.WriteLine(setOne);
Console.WriteLine(setTwo);
var union = setOne.Union(setTwo);
Console.WriteLine();
Console.WriteLine(union);
var intersect = setOne.Intersect(setTwo);
Console.WriteLine(intersect);
}
示例2: Main
static void Main(string[] args)
{
Set a = new Set();
a.Add(1);
a.Add(2);
a.Add(3);
Console.WriteLine("a : " + a);
Set b = new Set();
b.Add(2);
b.Add(3);
Console.WriteLine("b : " + b);
Set c = new Set();
c = a.Union(b);
Console.WriteLine("a.Union(b) : " + c);
c = a.Intersection(b);
Console.WriteLine("a.Intersection(b) : " + c);
c = a.Difference(b);
Console.WriteLine("a.Difference(b) : " + c);
bool flag;
flag = a.IsSubsetOf(b);
Console.WriteLine("a.IsSubsetOf(b) : " + flag);
flag = b.IsSubsetOf(a);
Console.WriteLine("b.IsSubsetOf(a) : " + flag);
Console.Read();
}
示例3: UnionTest
public void UnionTest()
{
var a = new Set<int>(1, 2, 3);
var b = new Set<int>(2, 3, 4);
Assert.AreEqual("{1,2,3,4}", a.Union(b).ToString());
}
示例4: Main
public static void Main()
{
var set1 = new Set<string>();
var set2 = new Set<string>();
set1.Add("one");
set1.Add("two");
set1.Add("three");
set2.Add("three");
set2.Add("four");
Console.WriteLine(set1);
Console.WriteLine(set2);
Console.WriteLine(set1.Intersect(set2));
Console.WriteLine(set2.Intersect(set1));
Console.WriteLine(set1.Union(set2));
Console.WriteLine(set2.Union(set1));
set1.Remove("five");
set1.Remove("two");
Console.WriteLine(set1);
Console.WriteLine(set1.Find("one"));
Console.WriteLine(set1.Find("two"));
Console.WriteLine(set1.Count);
}
示例5: Main
public static void Main()
{
var set = new Set<int>();
for (int i = 1; i < 11; i++)
{
for (int j = 0; j < 3; j++)
{
set.Add(i);
}
}
Console.WriteLine(set);
Console.WriteLine(set.Count);
var otherSet = new Set<int>();
for (int i = 5; i < 16; i++)
{
otherSet.Add(i);
}
Console.WriteLine(otherSet);
Console.WriteLine(otherSet.Count);
Console.WriteLine(set.IntersectsWith(otherSet));
Console.WriteLine(set.Union(otherSet));
}
示例6: Union
public void Union()
{
var s1 = new Set<string>() { "Apple", "Banana", "three" };
var s2 = new Set<string>() { "one", "Banana", "Apple" };
var s3 = s1.Union(s2);
Console.Out.WriteLine(s3);
Assert.That(s3, Has.Count.EqualTo(4), "Incorrect number of elements.");
}
示例7: AddToProcessBlacklist
/// <summary>
/// Process blacklist
/// Prevents javascript process access to server processes unless they're not on the blacklist
/// NOTE: The blacklist and whitelist is an either/or situation, you must decide on whether to
/// white or blacklist a set of processes.
/// </summary>
/// <param name="processes">Processes to add to the whitelist</param>
public static void AddToProcessBlacklist(IEnumerable<ProcessId> processes)
{
lock (sync)
{
Set<string> set = Set.createRange(processes.Map(x => x.Path).Distinct());
processBlacklist = processBlacklist == null
? processBlacklist = set
: processBlacklist.Union(set);
processWhitelist = null;
}
}
示例8: UnionTest
public void UnionTest()
{
Set<int> firstSet = new Set<int>(1, 2, 3, 4, 5);
Set<int> secondSet = new Set<int>(3, 4, 5, 6, 7);
Set<int> resultSet = firstSet.Union(secondSet);
Assert.IsTrue(resultSet.Contains(1));
Assert.IsTrue(resultSet.Contains(2));
Assert.IsTrue(resultSet.Contains(3));
Assert.IsTrue(resultSet.Contains(4));
Assert.IsTrue(resultSet.Contains(5));
Assert.IsTrue(resultSet.Contains(6));
Assert.IsTrue(resultSet.Contains(7));
}
示例9: UnionTest
public void UnionTest()
{
var firstSet = new Set<double>();
var secondSet = new Set<double>();
firstSet.Add(2.2);
firstSet.Add(20.1415926);
firstSet.Add(2.2);
secondSet.Add(10);
secondSet.Add(2.2);
var newSet = firstSet.Union(secondSet);
Assert.IsTrue(newSet.Contains(2.2));
Assert.IsTrue(newSet.Contains(10));
Assert.IsTrue(newSet.Contains(20.1415926));
}
示例10: ComplexTest
public void ComplexTest()
{
var firstSet = new Set<int>();
var secondSet = new Set<int>();
var thirdSet = new Set<int>();
for (int i = 0; i <= 100; ++i)
firstSet.Add(i);
for (int i = -50; i <= 50; ++i)
secondSet.Add(i);
for (int i = -50; i <= 100; i += 2)
thirdSet.Add(i);
var newSet = firstSet.Union(secondSet);
for (int i = -50; i <= 100; ++i)
Assert.IsTrue(newSet.Contains(i));
newSet = newSet.Intersection(thirdSet);
for (int i = -50; i <= 100; i += 2)
Assert.IsTrue(newSet.Contains(i));
newSet = newSet.Intersection(firstSet);
for (int i = 0; i <= 100; i += 2)
Assert.IsTrue(newSet.Contains(i));
for (int i = -50; i < 0; i += 2)
Assert.IsFalse(newSet.Contains(i));
}
示例11: HideReachable
/// <summary>
/// Hide all previously shown transitions from the given node
/// and those that can be reached recursively
/// </summary>
internal void HideReachable(Node node)
{
Set<Transition> alltransitions = this.hiddenTransitions.Union(this.transitions);
Set<Node> frontier = new Set<Term>(node);
Set<Node> visited = frontier;
Set<Transition> tobehidden = Set<Transition>.EmptySet;
while (!frontier.IsEmpty)
{
Node n = frontier.Choose(0);
frontier = frontier.Remove(n);
Set<Transition> toBeHiddenTransitions =
alltransitions.Select(delegate(Transition t) { return t.First.Equals(n); });
Set<Node> targetStates =
toBeHiddenTransitions.Convert<Node>(delegate(Transition t) { return t.Third; });
frontier = frontier.Union(targetStates.Difference(visited));
visited = visited.Union(targetStates);
tobehidden = tobehidden.Union(toBeHiddenTransitions);
}
this.hiddenTransitions = this.hiddenTransitions.Union(tobehidden);
this.transitions = this.transitions.Difference(tobehidden);
}
示例12: UnionTest
public void UnionTest()
{
var a = new Set<int>(1, 2, 3);
var b = new Set<int>(2, 3, 4);
Console.WriteLine(a.Union(b));
}
示例13: SimpleUnion
public void SimpleUnion() {
var set1 = new Set<int>();
var set2 = new Set<int>();
var expectedUnion = new Set<int>();
set1.Add(new [] { 1, 2 });
set2.Add(new [] { 3, 4 });
expectedUnion.Add(new [] { 1, 2, 3, 4 });
var union = set1.Union(set2);
Assert.Equals(expectedUnion, union);
}
示例14: RescuePSMsByClustering
//.........这里部分代码省略.........
var insertTempSpecIdscmd = session.Connection.CreateCommand();
insertTempSpecIdscmd.CommandText = "INSERT INTO TempSpecIds VALUES (?)";
var insertTempSpecIdsParameters = new List<System.Data.IDbDataParameter>();
for (int i = 0; i < 1; ++i)
{
insertTempSpecIdsParameters.Add(insertTempSpecIdscmd.CreateParameter());
insertTempSpecIdscmd.Parameters.Add(insertTempSpecIdsParameters[i]);
}
insertTempSpecIdscmd.Prepare();
foreach (var id in allSpectrumIDs)
{
insertTempSpecIdsParameters[0].Value = id;
insertTempSpecIdscmd.ExecuteNonQuery();
}
IList<object> allPsmIdQueryRows;
lock (session)
//// SQL query to retrieve all psm id for clustered spectra with score above a threshold
allPsmIdQueryRows = session.CreateSQLQuery(@"SELECT GROUP_CONCAT(psm.Id)
FROM TempSpecIds
JOIN UnfilteredPeptideSpectrumMatch psm ON TempSpecIds.Id = psm.Spectrum
JOIN PeptideSpectrumMatchScore psmScore ON psm.Id = psmScore.PsmId
JOIN PeptideSpectrumMatchScoreName scoreName ON psmScore.ScoreNameId=scoreName.Id
WHERE psm.Rank <= " + maxRank.ToString() + " AND ((scoreName.Name = " + "'" + searchScore1Name + "'" + " AND psmScore.Value " + searchScore1Order + searchScore1Threshold.ToString() + ") OR (scoreName.Name = " + "'" + searchScore2Name + "'" + " AND psmScore.Value " + searchScore2Order + searchScore2Threshold.ToString() + ") OR (scoreName.Name = " + "'" + searchScore3Name + "'" + " AND psmScore.Value " + searchScore3Order + searchScore3Threshold.ToString() + "))" +
" GROUP BY TempSpecIds.Id, psm.Charge"
).List<object>();
var allPsmIdsRows = allPsmIdQueryRows.Select(o => new PsmIdRow(o)).ToList();
Set<long> allPsmIds = new Set<long>();
foreach (var row in allPsmIdsRows)
{
allPsmIds.Union(row.PsmIds);
}
session.CreateSQLQuery(@"DROP TABLE IF EXISTS TempSpecIds").ExecuteUpdate();
reportStatus("Querying PSMs...");
reportProgress(-1, "Querying PSMs");
IList<object[]> allClusterQueryRows;
//// create a temp table to store psm IDs
session.CreateSQLQuery(@"DROP TABLE IF EXISTS TempPsmIds;
CREATE TEMP TABLE TempPsmIds (Id INTEGER PRIMARY KEY)
").ExecuteUpdate();
var cmd = session.Connection.CreateCommand();
cmd.CommandText = "INSERT INTO TempPsmIds VALUES (?)";
var parameters = new List<System.Data.IDbDataParameter>();
for (int i = 0; i < 1; ++i)
{
parameters.Add(cmd.CreateParameter());
cmd.Parameters.Add(parameters[i]);
}
cmd.Prepare();
foreach (var id in allPsmIds)
{
parameters[0].Value = id;
cmd.ExecuteNonQuery();
}
//// qurey string for revison 286, no DecoySequence in Peptide table
// string queryCmd = @"SELECT psm.Id as psmId, s.Id, source.Name, s.NativeID, psm.Rank, psm.Charge, psmScore.Value, IFNULL(GROUP_CONCAT(DISTINCT pm.Offset || ':' || mod.MonoMassDelta),''),
// (SELECT SUBSTR(pro.Sequence, pi.Offset+1, pi.Length)
// FROM PeptideInstance pi
示例15: Load
/// <summary>
/// Load all wordforms from ConcordanceTexts into cache.
/// </summary>
/// <param name="hvoWfi"></param>
/// <param name="tag"></param>
/// <param name="ws"></param>
/// <param name="cda"></param>
public override void Load(int hvoWfi, int ktagConcordanceWordforms, int ws, IVwCacheDa cda)
{
Debug.Assert(hvoWfi == m_cache.LangProject.WordformInventoryOAHvo);
List<int> concTexts = new List<int>(m_cache.GetVectorProperty(m_cache.LangProject.Hvo, LangProject.InterlinearTextsFlid(Cache), false));
// initialize our ConcordanceWords property.
cda.CacheVecProp(hvoWfi, ktagConcordanceWordforms, new int[0], 0);
// load all the text structure annotations.
ParagraphParser.ConcordTexts(m_cache, concTexts.ToArray(), Progress);
Set<int> wordformsFromSession = new Set<int>(ParagraphParser.WordformsFromLastParseSession(m_cache).ToArray());
// get all real wordforms and add the ones that have no occurrences in a text.
Set<int> wfiWordforms = new Set<int>(m_cache.LangProject.WordformInventoryOA.WordformsOC.HvoArray);
Set<int> fullConcordanceWordList = wordformsFromSession.Union(wfiWordforms); //UnionOfLists(wordformsFromSession, wfiWordforms);
Debug.Assert(m_cache.MainCacheAccessor.get_VecSize(hvoWfi, ktagConcordanceWordforms) == 0,
"The parse session should not have already added to our ConconcordanceWordforms");
// reload into our vector property
cda.CacheVecProp(hvoWfi, ktagConcordanceWordforms, fullConcordanceWordList.ToArray(), fullConcordanceWordList.Count);
}