本文整理汇总了C#中SortedSet类的典型用法代码示例。如果您正苦于以下问题:C# SortedSet类的具体用法?C# SortedSet怎么用?C# SortedSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SortedSet类属于命名空间,在下文中一共展示了SortedSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public static void Parse(SortedSet<string> list, Expression expr)
{
if (expr == null)
return;
BinaryExpression eb = expr as BinaryExpression;
MemberExpression em = expr as MemberExpression;
UnaryExpression eu = expr as UnaryExpression;
MethodCallExpression ec = expr as MethodCallExpression;
if (em != null) // member expression
{
list.Add(em.Member.Name);
}
else if (eb != null) // binary expression
{
Parse(list, eb.Left);
Parse(list, eb.Right);
}
else if (eu != null) // unary expression
{
Parse(list, eu.Operand);
}
else if (ec != null) // call expression
{
foreach (var a in ec.Arguments)
Parse(list, a);
}
return;
}
示例2: ReadStudentsInfoFromFile
private static void ReadStudentsInfoFromFile(string filePath, SortedDictionary<string, SortedSet<Student>> courses)
{
using (StreamReader reader = new StreamReader(filePath))
{
string line = reader.ReadLine();
while (line != string.Empty && line != null)
{
string[] data = line.Split('|');
string firstName = data[0].Trim();
string lastName = data[1].Trim();
string courseName = data[2].Trim();
if (courses.ContainsKey(courseName))
{
courses[courseName].Add(new Student(firstName, lastName));
}
else
{
courses[courseName] = new SortedSet<Student>();
courses[courseName].Add(new Student(firstName, lastName));
}
line = reader.ReadLine();
}
}
}
示例3: TestCollectionContains
public void TestCollectionContains()
{
var sortedSet = new SortedSet<int>();
sortedSet.Add(10);
sortedSet.Add(5);
sortedSet.Add(6);
sortedSet.Add(20);
sortedSet.Add(13);
sortedSet.Add(14);
Assert.IsTrue(sortedSet.Contains(10));
Assert.IsTrue(sortedSet.Contains(5));
Assert.IsTrue(sortedSet.Contains(6));
Assert.IsTrue(sortedSet.Contains(20));
Assert.IsTrue(sortedSet.Contains(13));
Assert.IsTrue(sortedSet.Contains(14));
for (int i = 0; i < 4; i++)
{
Assert.IsFalse(sortedSet.Contains(i));
}
for (int i = 21; i < 50; i++)
{
Assert.IsFalse(sortedSet.Contains(i));
}
}
示例4: buttonGerar_Click
private void buttonGerar_Click(object sender, EventArgs e)
{
Task.Run(() => {
ClearText();
Random random = new Random((int) DateTime.Now.Ticks);
SortedSet<string> numerosCertidao = new SortedSet<string>();
int quantidade;
if (!Int32.TryParse(textBoxQtd.Text, out quantidade)) {
InsertText(String.Format("Erro: \"{0}\" não é uma quantidade válida.", textBoxQtd.Text));
return;
}
while (numerosCertidao.Count() < quantidade) {
string numeroCertidao = CertidaoNascimentoHelper.GerarNumeroCertidao(random);
numeroCertidao =
numeroCertidao.Substring(0, 6) + " " +
numeroCertidao.Substring(6, 2) + " " +
numeroCertidao.Substring(8, 2) + " " +
numeroCertidao.Substring(10, 4) + " " +
numeroCertidao.Substring(14, 1) + " " +
numeroCertidao.Substring(15, 5) + " " +
numeroCertidao.Substring(20, 3) + " " +
numeroCertidao.Substring(23, 7) + " " +
numeroCertidao.Substring(30, 2);
numerosCertidao.Add(numeroCertidao);
}
foreach (var numero in numerosCertidao) {
InsertText(numero);
}
});
}
示例5: Main
static void Main()
{
Dictionary<string, SortedDictionary<string,SortedSet<string>>> NightLife = new Dictionary<string, SortedDictionary<string, SortedSet<string>>>();
string city = "";
string venue = "";
string performars = "";
string[] input = Console.ReadLine().Split(';');
while (input[0] != "END")
{
city = input[0];
venue = input[1];
performars = input[2];
if (!NightLife.ContainsKey(city))
{
NightLife[city] = new SortedDictionary<string, SortedSet<string>>();
}
if (!NightLife[city].ContainsKey(venue))
{
NightLife[city][venue] = new SortedSet<string>();
}
NightLife[city][venue].Add(performars);
input = Console.ReadLine().Split(';');
}
foreach (var cityPair in NightLife)
{
Console.WriteLine(cityPair.Key);
foreach (var venuePair in cityPair.Value)
{
Console.WriteLine("->{0}: {1}",venuePair.Key,String.Join(",",venuePair.Value));
}
}
}
示例6: LoadChildren
protected override void LoadChildren()
{
base.Children.Add(new ObjectViewModel(m_databaseLocation, this, m_databaseLocation.Session));
SortedSet<Database> dbSet = new SortedSet<Database>(m_databaseLocation.Session.OpenLocationDatabases(m_databaseLocation, false));
foreach (Database database in dbSet)
base.Children.Add(new DatabaseViewModel(this, database));
}
示例7: SetUp
public override void SetUp()
{
base.SetUp();
// we generate aweful regexps: good for testing.
// but for preflex codec, the test can be very slow, so use less iterations.
NumIterations = Codec.Default.Name.Equals("Lucene3x") ? 10 * RANDOM_MULTIPLIER : AtLeast(50);
Dir = NewDirectory();
RandomIndexWriter writer = new RandomIndexWriter(Random(), Dir, (IndexWriterConfig)NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random(), MockTokenizer.KEYWORD, false)).SetMaxBufferedDocs(TestUtil.NextInt(Random(), 50, 1000)));
Document doc = new Document();
Field field = NewStringField("field", "", Field.Store.YES);
doc.Add(field);
Terms = new SortedSet<BytesRef>();
int num = AtLeast(200);
for (int i = 0; i < num; i++)
{
string s = TestUtil.RandomUnicodeString(Random());
field.StringValue = s;
Terms.Add(new BytesRef(s));
writer.AddDocument(doc);
}
TermsAutomaton = BasicAutomata.MakeStringUnion(Terms);
Reader = writer.Reader;
Searcher = NewSearcher(Reader);
writer.Dispose();
}
示例8: ListTests_Exception
public void ListTests_Exception()
{
SortedSet<string> phoneNumbers = new SortedSet<string> { "+35929811111" };
PhonebookRepository phonebook = new PhonebookRepository();
phonebook.AddPhone("Kalina", phoneNumbers);
phonebook.ListEntries(10, 10);
}
示例9: AprioriGen
//产生候选集:使用《数据挖掘导论》上P210页的方法
static List<SortedSet<string>> AprioriGen(List<SortedSet<string>> kFequentSet)
{
List<SortedSet<string>> result = new List<SortedSet<string>>();
for (int i = 0; i < kFequentSet.Count; i++)
{
SortedSet<string> aTmpSet = new SortedSet<string>(kFequentSet[i]);
string aLastElement = kFequentSet[i].Last<string>();
aTmpSet.Remove(aLastElement);//去掉最后一个元素
for (int j = i + 1; j < kFequentSet.Count; j++)
{
SortedSet<string> bTmpSet = new SortedSet<string>(kFequentSet[j]);
string bLastElement = kFequentSet[j].Last<string>();
bTmpSet.Remove(bLastElement);//去掉最后一个元素
if (bTmpSet.Count == aTmpSet.Count)
{
bTmpSet.ExceptWith(aTmpSet);
if (bTmpSet.Count == 0 && !aLastElement.Equals(bLastElement))//前k-2个元素相同而最后一个元素不同
{
result.Add(new SortedSet<string>(kFequentSet[i]));
result[result.Count - 1].Add(bLastElement);
}
}
}
}
return result;
}
示例10: GetContactList
public ActionResult GetContactList()
{
if (!PingNotif())
{
return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
}
logger.LogActionEnter(Session.SessionID, "/Service/GetContactList");
SortedSet<GetContactListResponse_User> list = new SortedSet<GetContactListResponse_User>();
User user = UserManager.GetUser(System.Web.HttpContext.Current.User.Identity.Name);
Dictionary<string, User> contact_list = UserManager.GetContactList(user);
foreach(KeyValuePair<string, User> u in contact_list)
{
list.Add(new GetContactListResponse_User
{
user_id = u.Value.user_id,
login = u.Value.login,
nickname = u.Key,
status = (int)u.Value.status,
description = u.Value.descripton
});
}
logger.LogActionLeave(Session.SessionID, "/Service/GetContactList", list.Count + " contacts sent");
return Json(list.OrderBy(u => u.user_id));
}
示例11: Main
public static void Main()
{
Console.WriteLine("A TV company needs to lay cables to a new neighborhood (for every house).");
Console.WriteLine("Some of the paths are longer. Find a way to minimize the cost for cables.\n");
SortedSet<Edge> priority = new SortedSet<Edge>();
int numberOfNodes = 8;
bool[] used = new bool[numberOfNodes + 1];
List<Edge> mpdNodes = new List<Edge>();
List<Edge> edges = new List<Edge>();
InitializeGraph(edges);
Console.WriteLine("The paths from house to house are:");
//adding edges that connect the node 1 with all the others - 2, 3, 4
for (int i = 0; i < edges.Count; i++)
{
Console.WriteLine("{0}", edges[i]);
if (edges[i].StartNode == edges[0].StartNode)
{
priority.Add(edges[i]);
}
}
used[edges[0].StartNode] = true;
FindMinimumSpanningTree(used, priority, mpdNodes, edges);
PrintMinimumSpanningTree(mpdNodes);
}
示例12: Main
public static void Main(string[] args)
{
SortedDictionary<string, SortedSet<Fullname>> courseDictionary = new SortedDictionary<string, SortedSet<Fullname>>();
using (FileStream fs = new FileStream("students.txt", FileMode.Open))
{
StreamReader reader = new StreamReader(fs);
while (!reader.EndOfStream)
{
var lineItems = reader.ReadLine().Split('|').Select(x => x.Trim()).ToArray();
SortedSet<Fullname> students;
if (!courseDictionary.TryGetValue(lineItems[2], out students))
{
students = new SortedSet<Fullname>();
courseDictionary.Add(lineItems[2], students);
}
students.Add(new Fullname()
{
FirstName = lineItems[0],
LastName = lineItems[1]
});
}
}
foreach (var course in courseDictionary)
{
Console.WriteLine("{0}:{1}", course.Key, string.Join(",", course.Value));
}
}
示例13: ConvertForwardReferencesToNamespaces
public Namespace ConvertForwardReferencesToNamespaces(
IEnumerable<CLITypeReference> typeReferences)
{
// Create a new tree of namespaces out of the type references found.
var rootNamespace = new TranslationUnit();
rootNamespace.Module = TranslationUnit.Module;
var sortedRefs = typeReferences.ToList();
sortedRefs.Sort((ref1, ref2) =>
string.CompareOrdinal(ref1.FowardReference, ref2.FowardReference));
var forwardRefs = new SortedSet<string>();
foreach (var typeRef in sortedRefs)
{
if (string.IsNullOrWhiteSpace(typeRef.FowardReference))
continue;
var declaration = typeRef.Declaration;
if (!(declaration.Namespace is Namespace))
continue;
if (!forwardRefs.Add(typeRef.FowardReference))
continue;
if (typeRef.Include.InHeader)
continue;
var @namespace = FindCreateNamespace(rootNamespace, declaration);
@namespace.TypeReferences.Add(typeRef);
}
return rootNamespace;
}
示例14: Main
static void Main()
{
var findedAreas = new SortedSet<Area>();
for (int row = 0; row < matrix.GetLength(0); row++)
{
for (int col = 0; col < matrix.GetLength(1); col++)
{
if (matrix[row, col] == ' ')
{
GetConnectedAreaSize(row, col);
var area = new Area(row, col, areaSize);
findedAreas.Add(area);
areaSize = 0;
}
}
}
if (findedAreas.Any())
{
Console.WriteLine("Total areas found: {0}", findedAreas.Count);
int number = 0;
foreach (var area in findedAreas)
{
++number;
Console.WriteLine("Area #{0} at {1}", number, area.ToString());
}
}
}
示例15: ExecuteResult
/// <inheritdoc />
public override void ExecuteResult(ControllerContext context)
{
var response = context.HttpContext.Response;
response.StatusCode = 200;
response.ContentType = "application/x-" + this.service + "-advertisement";
response.BinaryWrite(ProtocolUtils.PacketLine("# service=" + this.service + "\n"));
response.BinaryWrite(ProtocolUtils.EndMarker);
var ids = new SortedSet<string>(this.repo.Refs.Select(r => r.TargetIdentifier));
var first = true;
foreach (var id in ids)
{
var line = first
? string.Format("{0} refs/anonymous/{0}\0{1}\n", id, this.GetCapabilities())
: string.Format("{0} refs/anonymous/{0}\n", id);
response.BinaryWrite(ProtocolUtils.PacketLine(line));
first = false;
}
if (first)
{
var line = string.Format("{0} capabilities^{{}}\0{1}\n", ProtocolUtils.ZeroId, this.GetCapabilities());
response.BinaryWrite(ProtocolUtils.PacketLine(line));
}
response.BinaryWrite(ProtocolUtils.EndMarker);
response.End();
}