示例#1
0
文件: DBTable.cs 项目: Adel-dz/Hub
        public void Delete(int[] ndxData)
        {
            Assert(IsConnected);
            Assert(ndxData != null);
            Assert(ndxData.Count(x => x < 0 || RowCount <= x) == 0);

            var indices = ndxData.OrderByDescending(x => x).ToArray();

            lock (m_rwLock)
            {
                for (int i = 0; i < indices.Length; ++i)
                {
                    m_writer.Position = 0;
                    m_writer.Write(m_header.FirstDeletedFrameIndex);

                    int  ndxFrame = RowIndexToFrameIndex(indices[i]);
                    long framePos = GetFramePosition(ndxFrame);
                    WriteFrame(framePos);
                    m_header.FirstDeletedFrameIndex = ndxFrame;

                    int loc = m_recycledData.BinarySearch(ndxFrame);

                    Assert(loc < 0);
                    m_recycledData.Insert(~loc, ndxFrame);
                }

                m_header.LastWriteTime = DateTime.Now;
                DataDeleted?.Invoke(indices);
            }
        }
示例#2
0
        private void Source_DataDeleted(IList <int> indices)
        {
            var data = new IDatum[indices.Count];

            Monitor.Enter(m_lock);

            for (int i = 0; i < indices.Count; ++i)
            {
                int ndx = indices[i];

                Assert(m_cache.ContainsKey(ndx));

                IDatum datum = m_cache[ndx];
                m_cache.Remove(ndx);
                m_ndxTable.Remove(datum.ID);

                data[i] = datum;

                var keys = from kv in m_ndxTable
                           where kv.Value > ndx
                           select kv.Key;

                keys.ToList().ForEach(k => -- m_ndxTable[k]);
            }

            Monitor.Exit(m_lock);

            DataDeleted?.Invoke(data);
        }
示例#3
0
        private void DataProvider_DataDeleted(IList <int> Indices)
        {
            using (Lock())
            {
                var data = new IDatum[Indices.Count];

                foreach (int ndx in Indices)
                {
                    IDatum datum = null;
                    int    i     = 0;

                    while (i < m_cache.Count)
                    {
                        int index = m_cache[i].Item1;

                        if (ndx < index)
                        {
                            IDatum d = m_cache[i].Item2;
                            m_cache[i] = Tuple.Create(index - 1, d);
                            ++i;
                        }
                        else if (index == ndx)
                        {
                            datum = m_cache[i].Item2;
                            m_cache.RemoveAt(i);
                        }
                    }


                    Assert(datum != null);
                    data[ndx] = datum;

                    T key = m_selector(datum);
                    m_dataIndices[key].Remove(ndx);

                    //adjust indices
                    foreach (List <int> lst in m_dataIndices.Values)
                    {
                        for (int k = 0; k < lst.Count; ++k)
                        {
                            if (ndx < lst[k])
                            {
                                --lst[k];
                            }
                        }
                    }
                }

                DataDeleted?.Invoke(data);
            }
        }
示例#4
0
            public void Delete(IList <int> indices)
            {
                Assert(IsConnected);
                Assert(indices != null);
                Assert(indices.Any(ndx => ndx < 0 || ndx >= Count) == false);

                lock (m_table)
                {
                    DataDeleting?.Invoke(indices);

                    m_table.Delete(indices);

                    if (AutoFlush)
                    {
                        m_table.Flush();
                    }

                    DataDeleted?.Invoke(indices);
                }
            }
示例#5
0
 private void OnNodeDataDeleted(TreeNode node)
 {
     DataDeleted?.Invoke(this, new EventArgs <object>(node.Tag));
 }
示例#6
0
 void Table_DataDeleted(int[] indices) => DataDeleted?.Invoke(indices);