private void CheckCollections() { Assert.AreEqual(str_native.Length, str_list.Count); int elem_len = math.min(str_native.Length, str_list.Count); for (int i = 0; i < elem_len; i++) { StringEntity entity = str_native[i]; string str_e = entity.ToString(); char[] c_arr_e = entity.ToArray(); ReadOnlyStringEntity entity_ro = entity.GetReadOnly(); string str = str_list[i]; char[] c_arr = str.ToCharArray(); Assert.AreEqual(str_e, str); Assert.AreEqual(c_arr_e.ToString(), c_arr.ToString()); Assert.IsTrue(entity.Equals(str)); Assert.IsTrue(entity.Equals(c_arr)); if (str.Length == 1) { Assert.IsTrue(entity.Equals(str[0])); } Assert.IsTrue(entity_ro.Equals(str)); Assert.IsTrue(entity_ro.Equals(c_arr)); if (str.Length == 1) { Assert.IsTrue(entity_ro.Equals(str[0])); } } }
private void ApplyRemoveAt(int n_RemoveAt) { if (str_native.Length <= 0 || str_list.Count <= 0) { return; } if (n_RemoveAt <= 0) { return; } Assert.AreEqual(str_native.Length, str_list.Count); int i_range = str_native.Length; int n_remove = math.min(n_RemoveAt, i_range); Debug.Log("str_native.Capacity = " + str_native.Capacity.ToString() + ", str_native.Size = " + str_native.Size.ToString() + ", str_native.IndexCapacity = " + str_native.IndexCapacity.ToString() + ", str_native.Length = " + str_native.Length.ToString() + " (before remove)"); for (int i = 0; i < n_remove; i++) { int index = random.Next(0, i_range); StringEntity entity = str_native.At(index); ReadOnlyStringEntity entity_ro = entity.GetReadOnly(); //Debug.Log("delete: index = " + index.ToString()); str_native.RemoveAt(index); str_list.RemoveAt(index); i_range--; } Debug.Log("str_native.Capacity = " + str_native.Capacity.ToString() + ", str_native.Size = " + str_native.Size.ToString() + ", str_native.IndexCapacity = " + str_native.IndexCapacity.ToString() + ", str_native.Length = " + str_native.Length.ToString() + " (after remove)"); str_native.ReAdjustment(); Debug.Log("str_native.Capacity = " + str_native.Capacity.ToString() + ", str_native.Size = " + str_native.Size.ToString() + ", str_native.IndexCapacity = " + str_native.IndexCapacity.ToString() + ", str_native.Length = " + str_native.Length.ToString() + " (after call 'ReAdjustment()')"); str_native.ShrinkToFit(); Debug.Log("str_native.Capacity = " + str_native.Capacity.ToString() + ", str_native.Size = " + str_native.Size.ToString() + ", str_native.IndexCapacity = " + str_native.IndexCapacity.ToString() + ", str_native.Length = " + str_native.Length.ToString() + " (after call 'ShrinkToFit()')"); }