Example #1
0
 public static void UnmergeList <T>(this List <T> p_list, List <T> p_otherList)
 {
     if (p_otherList != null)
     {
         List <T> v_dummyList = new List <T>();
         for (int i = 0; i < p_list.Count; i++)
         //foreach(T v_object in p_otherList)
         {
             T v_object = p_list[i];
             if (!p_otherList.Contains(v_object))
             {
                 v_dummyList.Add(v_object);
             }
         }
         p_list.Clear();
         for (int i = 0; i < v_dummyList.Count; i++)
         {
             try
             {
                 T v_object = v_dummyList[i];
                 if (!AOTHelper.IsNull(v_object))
                 {
                     p_list.Add(v_object);
                 }
             }
             catch
             {
                 UnityEngine.Debug.Log("An error occurred when trying to UnmergeList");
             }
         }
     }
 }
 public override bool Equals(object p_value)
 {
     if (p_value == this)
     {
         return(true);
     }
     if (!AOTHelper.IsNull(p_value))
     {
         try {
             AOTKeyValuePair <TKey, TValue> v_castedObject = p_value as AOTKeyValuePair <TKey, TValue>;
             if (v_castedObject != null)
             {
                                     #pragma warning disable 618
                 if (((AOTHelper.IsNull(v_castedObject.Key) && AOTHelper.IsNull(this.Key)) || v_castedObject.Comparer.Equals(this.Key)) &&
                                     #pragma warning restore 618
                     ((AOTHelper.IsNull(v_castedObject.Value) && AOTHelper.IsNull(this.Value)) || v_castedObject.Value.Equals(this.Value)))
                 {
                     return(true);
                 }
             }
         } catch {
         }
     }
     return(false);
 }
Example #3
0
 public bool ContainsNull()
 {
     for (int i = 0; i < this.Count; i++)
     {
         object v_object = this[i];
         if (AOTHelper.IsNull(v_object))
         {
             return(true);
         }
     }
     return(false);
 }
Example #4
0
    public void RemoveNulls()
    {
        AOTList <T> v_newList = new AOTList <T>();

        for (int i = 0; i < this.Count; i++)
        {
            T v_object = this[i];
            if (!AOTHelper.IsNull(v_object))
            {
                v_newList.Add(v_object);
            }
        }
        this.Clear();
        foreach (T v_object in v_newList)
        {
            this.AddWithoutCallEvents(v_object);
        }
    }
Example #5
0
    /// <summary>
    /// Returns 'true' if the specified item is within the list.
    /// </summary>

    public bool Contains(T item)
    {
        if (buffer == null)
        {
            return(false);
        }
        for (int i = 0; i < Count; ++i)
        {
            if (
                (AOTHelper.IsNull(buffer[i]) && AOTHelper.IsNull(item)) ||
                (!AOTHelper.IsNull(buffer[i]) && buffer[i].Equals(item))
                )
            {
                return(true);
            }
        }
        return(false);
    }
Example #6
0
    public static bool AddChecking <T>(this List <T> p_list, T p_object)
    {
        bool v_sucess = false;

        try
        {
            if (p_list != null && !AOTHelper.IsNull(p_object) &&
                !p_list.Contains(p_object))
            {
                p_list.Add(p_object);
                v_sucess = true;
            }
        }
        catch
        {
            UnityEngine.Debug.Log("An error occurred when trying to AddChecking");
        }
        return(v_sucess);
    }
Example #7
0
    public bool AddChecking(T p_object)
    {
        bool v_sucess = false;

        try
        {
            if (!AOTHelper.IsNull(p_object) &&
                !this.Contains(p_object))
            {
                this.Add(p_object);
                v_sucess = true;
            }
        }
        catch
        {
            UnityEngine.Debug.Log("An error occurred when trying to AddChecking");
        }
        return(v_sucess);
    }
Example #8
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);
    }
    public void RemovePairsWithNullKeys()
    {
        AOTList <TAOTPair> v_newList = new AOTList <TAOTPair> ();

        foreach (TAOTPair v_pairValue in this)
        {
            try {
                if (!AOTHelper.IsNull(v_pairValue.Key))
                {
                    v_newList.Add(v_pairValue);
                }
            } catch {
            }
        }
        this.Clear();
        foreach (TAOTPair v_pairValue in v_newList)
        {
            this.AddWithoutCallEvents(v_pairValue);
        }
    }
Example #10
0
    public static void RemoveNulls <T>(this List <T> p_list) where T : class
    {
        if (p_list != null)
        {
            List <T> v_newList = new List <T>();

            for (int i = 0; i < p_list.Count; i++)
            {
                T v_object = p_list[i];
                if (!AOTHelper.IsNull(v_object))
                {
                    v_newList.Add(v_object);
                }
            }
            p_list.Clear();
            foreach (T v_object in v_newList)
            {
                p_list.Add(v_object);
            }
        }
    }
Example #11
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);
    }