コード例 #1
0
 public static void UnmergeList <T>(this IList <T> p_list, IList <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 (!EqualityExtension.IsNull(v_object))
                 {
                     p_list.Add(v_object);
                 }
             }
             catch
             {
                 UnityEngine.Debug.Log("An error occurred when trying to UnmergeList");
             }
         }
     }
 }
コード例 #2
0
        public static bool AddChecking <T>(this IList <T> p_list, T p_object)
        {
            bool v_sucess = false;

            try
            {
                if (p_list != null && !EqualityExtension.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);
        }
コード例 #3
0
        public static void RemoveNulls <T>(this IList <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 (!EqualityExtension.IsNull(v_object))
                    {
                        v_newList.Add(v_object);
                    }
                }
                p_list.Clear();
                foreach (T v_object in v_newList)
                {
                    p_list.Add(v_object);
                }
            }
        }
コード例 #4
0
        public static bool RemoveChecking <T>(this IList <T> p_list, T p_object, bool p_removeNulls = true)
        {
            bool v_sucess = false;

            if (p_list != null && !EqualityExtension.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 || !EqualityExtension.IsNull(v_object))
                        {
                            if (!EqualityExtension.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);
        }