mirror of
https://github.com/chylex/Code-Statistics.git
synced 2025-08-16 06:31:41 +02:00
CodeStatistics
CodeStatisticsCore
Collections
AnonymousDictionary.cs
BiDictionary.cs
CharacterRangeSet.cs
CounterDictionary.cs
EnumDictionary.cs
Node.cs
TopElementList.cs
Handling
Input
Properties
CodeStatisticsCore.csproj
CodeStatisticsTests
LanguageJava
.gitignore
CodeStatistics.sln
README.md
30 lines
994 B
C#
30 lines
994 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace CodeStatisticsCore.Collections{
|
|
public class CharacterRangeSet : IEnumerable<KeyValuePair<int, int>>{
|
|
private readonly List<KeyValuePair<int, int>> innerList = new List<KeyValuePair<int, int>>();
|
|
|
|
public void Add(int lowerBound, int upperBound){
|
|
innerList.Add(new KeyValuePair<int, int>(lowerBound, upperBound));
|
|
}
|
|
|
|
public bool Contains(int character){
|
|
foreach(KeyValuePair<int, int> kvp in innerList){
|
|
if (character < kvp.Key)return false; // all following KVPs are higher
|
|
if (character >= kvp.Key && character <= kvp.Value)return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public IEnumerator<KeyValuePair<int, int>> GetEnumerator(){
|
|
return innerList.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator(){
|
|
return innerList.GetEnumerator();
|
|
}
|
|
}
|
|
}
|