Free cookie consent management tool by TermsFeed Policy Generator

Changeset 69


Ignore:
Timestamp:
03/17/08 10:22:09 (16 years ago)
Author:
mkofler
Message:

Ticket #51: Added ItemList wrapper for ConvertAll and a few other methods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data/ItemList_T.cs

    r68 r69  
    4747    protected void CloneElements(ItemList<T> destination, IDictionary<Guid, object> clonedObjects) {
    4848      for (int i = 0; i < list.Count; i++)
    49         destination.list.Add((T)Auxiliary.Clone(list[i],clonedObjects));
     49        destination.list.Add((T) Auxiliary.Clone(list[i], clonedObjects));
    5050    }
    5151
     
    140140
    141141    #region List<T> Methods
     142    public int LastIndexOf(T item) {
     143      return list.LastIndexOf(item);
     144    }
     145
     146    public int LastIndexOf(T item, int index) {
     147      return list.LastIndexOf(item, index);
     148    }
     149
     150    public int LastIndexOf(T item, int index, int count) {
     151      return list.LastIndexOf(item, index, count);
     152    }
     153
     154    public int IndexOf(T item, int index) {
     155      return list.IndexOf(item, index);
     156    }
     157
     158    public int IndexOf(T item, int index, int count) {
     159      return list.IndexOf(item, index, count);
     160    }
     161
    142162    public void AddRange(IEnumerable<T> collection) {
    143163      foreach (T obj in collection) {
     
    150170    }
    151171
     172    public int BinarySearch(T item) {
     173      return list.BinarySearch(item);
     174    }
     175
     176    public int BinarySearch(T item, IComparer<T> comparer) {
     177      return list.BinarySearch(item, comparer);
     178    }
     179
     180    public int BinarySearch(int index, int count, T item, IComparer<T> comparer) {
     181      return list.BinarySearch(index, count, item, comparer);
     182    }
     183
    152184    public T Find(Predicate<T> match) {
    153185      return list.Find(match);
     
    159191
    160192    public int FindIndex(Predicate<T> match) {
    161       return list.FindIndex(match);
     193      return list.FindIndex(match);
     194    }
     195
     196    public T FindLast(Predicate<T> match) {
     197      return list.FindLast(match);
     198    }
     199
     200    public int FindLastIndex(Predicate<T> match) {
     201      return list.FindLastIndex(match);
    162202    }
    163203
    164204    public void Sort() {
    165       list.Sort(); 
     205      list.Sort();
    166206    }
    167207
    168208    public void Sort(IComparer<T> comparer) {
    169       list.Sort(comparer); 
     209      list.Sort(comparer);
    170210    }
    171211
    172212    public void Sort(Comparison<T> comparison) {
    173       list.Sort(comparison); 
    174     }   
     213      list.Sort(comparison);
     214    }
    175215
    176216    public void Reverse() {
    177      list.Reverse();
    178     }
     217      list.Reverse();
     218    }
     219
     220    public ItemList<TOutput> ConvertAll<TOutput>(Converter<T, TOutput> converter) where TOutput : IItem {
     221      ItemList<TOutput> targetList = new ItemList<TOutput>();
     222      foreach (T item in list) {
     223        targetList.Add(converter.Invoke(item));
     224      }
     225      return targetList;
     226    }
     227
     228    public bool TrueForAll(Predicate<T> match) {
     229      return list.TrueForAll(match);
     230    }
     231
    179232    #endregion
    180233
Note: See TracChangeset for help on using the changeset viewer.