manusoftar

Untitled

Sep 30th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using GTA;
  6.  
  7. namespace GTAModCSHARP  {
  8.    class MiLista<T>  : List<AutoBomba>  {
  9.        
  10.         public int Find(AutoBomba ab) {
  11.             for (int n = 0; n < this.Count; n++) {
  12.                 if (this.ElementAt<AutoBomba>(n).getAuto().GetHashCode() == ab.getAuto().GetHashCode()) {
  13.                     return n;
  14.                 }
  15.             }
  16.             return -1;
  17.         }
  18.  
  19.         public int Find(Vehicle v) {
  20.             for (int n = 0; n < this.Count; n++) {
  21.                 if (this.ElementAt<AutoBomba>(n).getAuto().GetHashCode() == v.GetHashCode()) {
  22.                     return n;
  23.                 }
  24.             }
  25.             return -1;
  26.         }
  27.  
  28.         public bool Contains(Vehicle v) {
  29.             foreach (AutoBomba abomb in this) {
  30.                 if (abomb.getAuto().GetHashCode() == v.GetHashCode()) {
  31.                     return true;
  32.                 }
  33.             }
  34.             return false;
  35.         }
  36.  
  37.         public AutoBomba get(Vehicle v) {
  38.             if (this.Contains(v)) {
  39.                 return this.ElementAt<AutoBomba>(this.Find(v));
  40.             } else {
  41.                 return null;
  42.             }
  43.         }
  44.  
  45.  
  46.         public void Remove(Vehicle v) {
  47.             if (this.Contains(v)) {
  48.                 int pos = this.Find(v);
  49.                 this.RemoveAt(pos);
  50.             }
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment