File: Handlers\Items\iOS\IndexPathExtensions.cs
Web Access
Project: src\src\Controls\src\Core\Controls.Core.csproj (Microsoft.Maui.Controls)
#nullable disable
using Foundation;
 
namespace Microsoft.Maui.Controls.Handlers.Items
{
	internal static class IndexPathExtensions
	{
		public static bool IsLessThanOrEqualToPath(this NSIndexPath path, NSIndexPath otherPath)
		{
			if (path.Section < otherPath.Section)
			{
				return true;
			}
 
			if (path.Section == otherPath.Section)
			{
				return path.Item <= otherPath.Item;
			}
 
			return false;
		}
 
		public static NSIndexPath FindFirst(this NSIndexPath[] paths)
		{
			NSIndexPath firstPath = null;
			foreach (var path in paths)
			{
				if (firstPath == null)
				{
					firstPath = path;
					continue;
				}
 
				if (path.IsLessThanOrEqualToPath(firstPath))
				{
					firstPath = path;
				}
			}
 
			return firstPath;
		}
	}
}