MeGaDeTH_91

SimpleSortedList Constructors

Apr 12th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public SimpleSortedList(IComparer<T> comparison, int capacity)
  2. {
  3. if (capacity < 0)
  4. {
  5. throw new ArgumentException("Capacity cannot be negative");
  6. }
  7.  
  8. this.comparison = comparison;
  9. this.innerCollection = new T[capacity];
  10. }
  11.  
  12. public SimpleSortedList(int capacity)
  13. : this(Comparer<T>.Create((x, y) => x.CompareTo(y)), capacity)
  14. {
  15. }
  16.  
  17. public SimpleSortedList(IComparer<T> comparison)
  18. : this(comparison, DefaultCapacity)
  19. {
  20. }
  21.  
  22.  
  23. public SimpleSortedList()
  24. : this(Comparer<T>.Create((x, y) => x.CompareTo(y)), DefaultCapacity)
  25. {
  26. }
Advertisement
Add Comment
Please, Sign In to add comment