EkaSe / Calculator

1 stars 1 forks source link

Collections: MyList Data Querying Methods #1

Closed acrm closed 7 years ago

acrm commented 7 years ago

Define in MyList class this instance methods:

  1. public MyList Where(Func<T, bool> predicate) {...} - returns new MyList collection, containing only those elements, for which predicate gives True
  2. public MyList Select(Func<T1, T2> select) {...} - returns new MyList collection, containing all new elements of type T2, created by applying selector for each element in the source collection
  3. public T[] ToArray() {...} - returns new array of elements of type T, copied from the collection
  4. public T FirstOrDefault() {...} - returns the very first element of source collection, if it contains any, otherwise returns default value of type T
  5. public T FirstOrDefault(Func<T, bool> predicate) {...} - returns the very first element of the source collection, for which predicate returns True, if any, otherwise returns default value of type T
acrm commented 7 years ago

Nice done! The tricky things is that all this fucntional of this branch will be removed by issue3 branch, cause there it moved to Extensions class) Nevertheless it's a good chance for practicing branches syncronization. First merge this branch to Master, than pull updates to Issue3 branch and there remove this methods from MyList class.