using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Arrays
{
    class Examples14_15
    {
        public static void SearchWithIndexOf()
        {
            string[] myRecentFiles = { @"c:\foo\bar.txt", @"c:\spong\quux.txt", @"c:\wibble\plunk.txt" };
            string openedFile = @"c:\spong\quux.txt";

            // Listing 5-14
            int recentFileListIndex = Array.IndexOf(myRecentFiles, openedFile);
            if (recentFileListIndex < 0)
            {
                AddNewRecentEntry(openedFile);
            }
            else
            {
                MoveExistingRecentEntryToTop(recentFileListIndex);
            }
        }

        private static void AddNewRecentEntry(string openedFile)
        {
        }

        private static void MoveExistingRecentEntryToTop(int recentFileListIndex)
        {
        }

        // Listing 5-15
        public static int GetIndexOfFirstNonEmptyBin(int[] bins)
        {
            return Array.FindIndex(bins, IsGreaterThanZero);
        }

        private static bool IsGreaterThanZero(int value)
        {
            return value > 0;
        }

    }
}
