internal int Remove(object item, bool returnLeafIndex)
        {
            int index      = -1;
            int localIndex = ProtectedItems.IndexOf(item);

            if (localIndex >= 0)
            {
                if (returnLeafIndex)
                {
                    index = LeafIndexFromItem(null, localIndex);
                }

                CollectionViewGroupInternal subGroup = item as CollectionViewGroupInternal;
                if (subGroup != null)
                {
                    subGroup.Clear();

                    // Remove from the name to group map.
                    RemoveSubgroupFromMap(subGroup);
                }

                ChangeCounts(item, -1);

                // ChangeCounts may clear this group, if it is now empty.
                // In that case, don't use localIndex - it's now out of range.
                if (ProtectedItems.Count > 0)
                {
                    ProtectedItems.RemoveAt(localIndex);
                }
            }

            return(index);
        }
示例#2
0
        /// <summary>
        /// Removes the specified item from the collection
        /// </summary>
        /// <param name="item">Item to remove</param>
        /// <param name="returnLeafIndex">Whether we want to return the leaf index</param>
        /// <returns>Leaf index where item was removed, if value was specified. Otherwise '-1'</returns>
        internal int Remove(object item, bool returnLeafIndex)
        {
            int index      = -1;
            int localIndex = ProtectedItems.IndexOf(item);

            if (localIndex >= 0)
            {
                if (returnLeafIndex)
                {
                    index = LeafIndexFromItem(null, localIndex);
                }

                ChangeCounts(item, -1);
                ProtectedItems.RemoveAt(localIndex);
            }

            return(index);
        }
示例#3
0
        internal int Remove(object item, bool returnLeafIndex)
        {
            int index      = -1;
            int localIndex = ProtectedItems.IndexOf(item);

            if (localIndex >= 0)
            {
                if (returnLeafIndex)
                {
                    index = LeafIndexFromItem(null, localIndex);
                }

                CollectionViewGroupInternal subGroup = item as CollectionViewGroupInternal;
                if (subGroup != null)
                {
                    // Remove from the name to group map.
                    RemoveSubgroupFromMap(subGroup);
                }
                ChangeCounts(item, -1);
                ProtectedItems.RemoveAt(localIndex);
            }

            return(index);
        }
示例#4
0
 internal int IndexOf(object item)
 {
     return(ProtectedItems.IndexOf(item));
 }