DynamicDiskExtentsHelper.cs 1.0 KB

123456789101112131415161718192021222324252627282930
  1. /* Copyright (C) 2014-2016 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. namespace DiskAccessLibrary.LogicalDiskManager
  11. {
  12. public class DynamicDiskExtentsHelper
  13. {
  14. /// <summary>
  15. /// Sort (in-place) extents by first sector
  16. /// </summary>
  17. public static void SortExtentsByFirstSector(List<DynamicDiskExtent> extents)
  18. {
  19. SortedList<long, DynamicDiskExtent> list = new SortedList<long, DynamicDiskExtent>();
  20. foreach (DynamicDiskExtent extent in extents)
  21. {
  22. list.Add(extent.FirstSector, extent);
  23. }
  24. extents.Clear();
  25. extents.AddRange(list.Values);
  26. }
  27. }
  28. }