Acceleratio.SPDG.Generator.SampleData.GetRandomNonRepeatingValues C# (CSharp) Method

GetRandomNonRepeatingValues() public static method

public static GetRandomNonRepeatingValues ( IList collection, int valuesCount, int defaultValueIndex ) : IList
collection IList
valuesCount int
defaultValueIndex int
return IList
        public static IList<string> GetRandomNonRepeatingValues(IList<string> collection, int valuesCount, int defaultValueIndex = 0)
        {
            var indexes = new List<int>();
            var collectionCount = collection.Count;

            for (var i = 0; i < collectionCount; i++)
            {
                indexes.Add(i);
            }

            indexes.Shuffle();

            var randomValues = new List<string>();
            for (var i = 0; i < valuesCount; i++)
            {
                if (i >= collectionCount)
                {
                    randomValues.Add(collection[defaultValueIndex]);
                }
                else
                {
                    randomValues.Add(collection[indexes[i]]);
                }
            }

            return randomValues;
        }