Exemplo n.º 1
0
 public static int ObjectIndex <T>(this List <T> p_list, T p_object)
 {
     for (int i = 0; i < p_list.Count; i++)
     {
         if (AOTHelper.Equals(p_list[i], p_object))
         {
             return(i);
         }
     }
     return(-1);
 }
Exemplo n.º 2
0
 public int ObjectIndex(T p_object)
 {
     for (int i = 0; i < this.Count; i++)
     {
         if (AOTHelper.Equals(this[i], p_object))
         {
             return(i);
         }
     }
     return(-1);
 }
Exemplo n.º 3
0
 public bool ContainsValue(TValue p_value)
 {
     foreach (TAOTPair v_pairValue in this)
     {
         try {
             if (AOTHelper.Equals(v_pairValue.Value, p_value))
             {
                 return(true);
             }
         } catch {
         }
     }
     return(false);
 }
Exemplo n.º 4
0
 public TAOTPair GetPairByValue(TValue p_value)
 {
     foreach (TAOTPair v_pairValues in this)
     {
         try {
             if (AOTHelper.Equals(v_pairValues.Value, p_value))
             {
                 return(v_pairValues);
             }
         } catch {
         }
     }
     return(default(TAOTPair));
 }
Exemplo n.º 5
0
 public bool ContainsKey(TKey p_key)
 {
     foreach (TAOTPair v_pairValue in this)
     {
         try {
             if (AOTHelper.Equals(v_pairValue.Key, p_key))
             {
                 return(true);
             }
         } catch {
         }
     }
     return(false);
 }
Exemplo n.º 6
0
 public TAOTPair GetPairByKey(TKey p_key)
 {
     foreach (TAOTPair v_pairValues in this)
     {
         try {
             if (AOTHelper.Equals(v_pairValues.Key, p_key))
             {
                 //if(p_key.Equals(v_pairValues.Comparer))
                 return(v_pairValues);
             }
         } catch {
         }
     }
     return(default(TAOTPair));
 }
Exemplo n.º 7
0
 public TKey GetKeyByValue(TValue p_value)
 {
     foreach (TAOTPair v_pairValues in this)
     {
         try {
             if (AOTHelper.Equals(v_pairValues.Value, p_value))
             {
                 //if(p_value.Equals(v_pairValues.Object))
                 return(v_pairValues.Key);
             }
         } catch {
         }
     }
     return(default(TKey));
 }
Exemplo n.º 8
0
    public bool RemoveByKey(TKey p_key)
    {
        TAOTPair v_removePair = default(TAOTPair);

        foreach (TAOTPair v_pairValue in this)
        {
            try {
                if (AOTHelper.Equals(v_pairValue.Key, p_key))
                {
                    v_removePair = v_pairValue;
                    break;
                }
            } catch {
            }
        }
        return(this.RemoveChecking(v_removePair));
    }
Exemplo n.º 9
0
    public bool RemoveChecking(TValue p_value)
    {
        TAOTPair v_removePair = default(TAOTPair);

        foreach (TAOTPair v_pairValue in this)
        {
            try {
                if (AOTHelper.Equals(v_pairValue.Value, p_value))
                {
                    v_removePair = v_pairValue;
                    break;
                }
            } catch {
            }
        }
        return(this.RemoveChecking(v_removePair));
    }
Exemplo n.º 10
0
    public AOTList <TValue> GetAllValueByKey(TKey p_key)
    {
        AOTList <TValue> v_values = new AOTList <TValue> ();

        foreach (TAOTPair v_pairValues in this)
        {
            try {
                if (AOTHelper.Equals(v_pairValues.Key, p_key))
                {
                    //if(p_key.Equals(v_pairValues.Comparer))
                    v_values.Add(v_pairValues.Value);
                }
            } catch {
            }
        }
        return(v_values);
    }
Exemplo n.º 11
0
    public bool RemoveChecking(T p_object, bool p_removeNulls = true)
    {
        bool v_sucess = false;

        if (!AOTHelper.IsNull(p_object))
        {
            if (p_removeNulls)
            {
                RemoveNulls();
            }
            AOTList <T> v_newList = new AOTList <T>();
            for (int i = 0; i < this.Count; i++)
            {
                try
                {
                    T v_object = this[i];
                    if (!AOTHelper.Equals(p_object, v_object))
                    {
                        v_newList.Add(v_object);
                    }
                    else
                    {
                        v_sucess = true;
                    }
                }
                catch
                {
                    UnityEngine.Debug.Log("An error occurred when trying to RemoveChecking");
                    v_sucess = true;
                }
            }
            this.Clear();
            foreach (T v_object in v_newList)
            {
                this.AddWithoutCallEvents(v_object);
            }
        }
        if (v_sucess)
        {
            OnRemove(p_object);
        }
        return(v_sucess);
    }
Exemplo n.º 12
0
    public void AddChecking(TKey p_key, TValue p_value)
    {
        bool v_found = false;

        foreach (TAOTPair v_pair in this)
        {
            try {
                if (AOTHelper.Equals(v_pair.Value, p_value) &&
                    AOTHelper.Equals(v_pair.Key, p_key))
                {
                    v_found = true;
                    break;
                }
            } catch {
            }
        }
        if (!v_found)
        {
            Add(p_key, p_value);
        }
    }
Exemplo n.º 13
0
    public static bool RemoveChecking <T>(this List <T> p_list, T p_object, bool p_removeNulls = true)
    {
        bool v_sucess = false;

        if (p_list != null && !AOTHelper.IsNull(p_object))
        {
            List <T> v_newList = new List <T>();
            for (int i = 0; i < p_list.Count; i++)
            {
                try
                {
                    T v_object = p_list[i];
                    if (!p_removeNulls || !AOTHelper.IsNull(v_object))
                    {
                        if (!AOTHelper.Equals(p_object, v_object))
                        {
                            v_newList.Add(v_object);
                        }
                        else
                        {
                            v_sucess = true;
                        }
                    }
                }
                catch
                {
                    UnityEngine.Debug.Log("An error occurred when trying to RemoveChecking");
                    v_sucess = true;
                }
            }
            p_list.Clear();
            foreach (T v_object in v_newList)
            {
                p_list.Add(v_object);
            }
        }
        return(v_sucess);
    }
Exemplo n.º 14
0
    public void AddReplacing(TKey p_key, TValue p_value)
    {
        bool v_found = false;

        for (int i = 0; i < this.Count; i++)
        {
            try {
                if (AOTHelper.Equals(this [i].Key, p_key))
                {
                    v_found = true;
                    TAOTPair v_pair = new TAOTPair();
                    v_pair.Value = p_value;
                    v_pair.Key   = p_key;
                    this [i]     = v_pair;
                    break;
                }
            } catch {
            }
        }
        if (!v_found)
        {
            Add(p_key, p_value);
        }
    }