本文整理汇总了C#中Model.Dictionary.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.Clear方法的具体用法?C# Dictionary.Clear怎么用?C# Dictionary.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Dictionary
的用法示例。
在下文中一共展示了Dictionary.Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateNumbersAndDistances
private void UpdateNumbersAndDistances(SelectionScope scope)
{
////////////////////////////////////////////////////////////////////////////////////
// update numbers
////////////////////////////////////////////////////////////////////////////////////
int chapter_number = 1;
int verse_number = 1;
int word_number = 1;
int letter_number = 1;
if (this.chapters != null)
{
// update verse/word/letter numbers
foreach (Chapter chapter in this.chapters)
{
chapter.Number = chapter_number++;
int verse_number_in_chapter = 1;
int word_number_in_chapter = 1;
int letter_number_in_chapter = 1;
foreach (Verse verse in chapter.Verses)
{
verse.Number = verse_number++;
verse.NumberInChapter = verse_number_in_chapter++;
int word_number_in_verse = 1;
int letter_number_in_verse = 1;
foreach (Word word in verse.Words)
{
word.Number = word_number++;
word.NumberInChapter = word_number_in_chapter++;
word.NumberInVerse = word_number_in_verse++;
int letter_number_in_word = 1;
foreach (Letter letter in word.Letters)
{
letter.Number = letter_number++;
letter.NumberInChapter = letter_number_in_chapter++;
letter.NumberInVerse = letter_number_in_verse++;
letter.NumberInWord = letter_number_in_word++;
}
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
// update positions and distances
////////////////////////////////////////////////////////////////////////////////////
// foreach chapter: no repeated chapters so no distances to previous same chapter
// foreach verse: calculate distance to its previous occurrence
Dictionary<string, int> verse_previous_verse_numbers = new Dictionary<string, int>();
Dictionary<string, int> verse_previous_chapter_numbers = new Dictionary<string, int>();
// foreach word: calculate distance to its previous occurrence
Dictionary<string, int> word_previous_word_numbers = new Dictionary<string, int>();
Dictionary<string, int> word_previous_verse_numbers = new Dictionary<string, int>();
Dictionary<string, int> word_previous_chapter_numbers = new Dictionary<string, int>();
// foreach letter: calculate distance to its previous occurrence
Dictionary<char, int> letter_previous_letter_numbers = new Dictionary<char, int>();
Dictionary<char, int> letter_previous_word_numbers = new Dictionary<char, int>();
Dictionary<char, int> letter_previous_verse_numbers = new Dictionary<char, int>();
Dictionary<char, int> letter_previous_chapter_numbers = new Dictionary<char, int>();
if (this.chapters != null)
{
foreach (Chapter chapter in this.chapters)
{
if (scope == SelectionScope.Chapter)
{
// there are no repeated chapters so there is no chapter_previous_chapter_numbers to clear
verse_previous_verse_numbers.Clear();
verse_previous_chapter_numbers.Clear();
word_previous_word_numbers.Clear();
word_previous_verse_numbers.Clear();
word_previous_chapter_numbers.Clear();
letter_previous_letter_numbers.Clear();
letter_previous_word_numbers.Clear();
letter_previous_verse_numbers.Clear();
letter_previous_chapter_numbers.Clear();
}
foreach (Verse verse in chapter.Verses)
{
string verse_text = verse.Text;
if (!verse_previous_verse_numbers.ContainsKey(verse_text))
{
verse.DistanceToPrevious.dL = -1; // non-applicable
verse.DistanceToPrevious.dW = -1; // non-applicable
verse.DistanceToPrevious.dV = 0;
verse.DistanceToPrevious.dC = 0;
verse_previous_verse_numbers.Add(verse_text, verse.Number);
verse_previous_chapter_numbers.Add(verse_text, verse.Chapter.Number);
}
//.........这里部分代码省略.........