示例#1
0
文件: Trie.cs 项目: wbj808178/netmq
        private void ApplyHelper(byte[] buff, int buffsize, int maxbuffsize, TrieDelegate func,
                                 Object arg)
        {
            //  If this node is a subscription, apply the function.
            if (m_refcnt > 0)
            {
                func(buff, buffsize, arg);
            }

            //  Adjust the buffer.
            if (buffsize >= maxbuffsize)
            {
                maxbuffsize = buffsize + 256;
                buff        = Utils.Realloc(buff, maxbuffsize);
                Debug.Assert(buff != null);
            }

            //  If there are no subnodes in the trie, return.
            if (m_count == 0)
            {
                return;
            }

            //  If there's one subnode (optimisation).
            if (m_count == 1)
            {
                buff[buffsize] = m_min;
                buffsize++;
                m_next[0].ApplyHelper(buff, buffsize, maxbuffsize, func, arg);
                return;
            }

            //  If there are multiple subnodes.
            for (short c = 0; c != m_count; c++)
            {
                buff[buffsize] = (byte)(m_min + c);
                if (m_next[c] != null)
                {
                    m_next[c].ApplyHelper(buff, buffsize + 1, maxbuffsize,
                                          func, arg);
                }
            }
        }
示例#2
0
        private void ApplyHelper(byte[] buffer, int bufferSize, int maxBufferSize, TrieDelegate func, object arg)
        {
            // If this node is a subscription, apply the function.
            if (m_referenceCount > 0)
            {
                func(buffer, bufferSize, arg);
            }

            // Adjust the buffer.
            if (bufferSize >= maxBufferSize)
            {
                maxBufferSize = bufferSize + 256;
                Array.Resize(ref buffer, maxBufferSize);
                Debug.Assert(buffer != null);
            }

            // If there are no subnodes in the trie, return.
            if (m_count == 0)
            {
                return;
            }

            // If there's one subnode (optimisation).
            if (m_count == 1)
            {
                buffer[bufferSize] = m_minCharacter;
                bufferSize++;
                m_next[0].ApplyHelper(buffer, bufferSize, maxBufferSize, func, arg);
                return;
            }

            // If there are multiple subnodes.
            for (short c = 0; c != m_count; c++)
            {
                buffer[bufferSize] = (byte)(m_minCharacter + c);
                if (m_next[c] != null)
                {
                    m_next[c].ApplyHelper(buffer, bufferSize + 1, maxBufferSize, func, arg);
                }
            }
        }
示例#3
0
 // Apply the function supplied to each subscription in the trie.
 public void Apply([NotNull] TrieDelegate func, [CanBeNull] object arg)
 {
     ApplyHelper(null, 0, 0, func, arg);
 }
示例#4
0
文件: Trie.cs 项目: JayShelton/netmq
        private void ApplyHelper(byte[] buff, int buffsize, int maxbuffsize, TrieDelegate func,
                                  Object arg)
        {
            //  If this node is a subscription, apply the function.
            if (m_refcnt > 0)
                func(buff, buffsize, arg);

            //  Adjust the buffer.
            if (buffsize >= maxbuffsize)
            {
                maxbuffsize = buffsize + 256;
                buff = Utils.Realloc(buff, maxbuffsize);
                Debug.Assert(buff != null);
            }

            //  If there are no subnodes in the trie, return.
            if (m_count == 0)
                return;

            //  If there's one subnode (optimisation).
            if (m_count == 1)
            {
                buff[buffsize] = m_min;
                buffsize++;
                m_next[0].ApplyHelper(buff, buffsize, maxbuffsize, func, arg);
                return;
            }

            //  If there are multiple subnodes.
            for (short c = 0; c != m_count; c++)
            {
                buff[buffsize] = (byte)(m_min + c);
                if (m_next[c] != null)
                    m_next[c].ApplyHelper(buff, buffsize + 1, maxbuffsize,
                                          func, arg);
            }
        }
示例#5
0
文件: Trie.cs 项目: JayShelton/netmq
 //  Apply the function supplied to each subscription in the trie.
 public void Apply(TrieDelegate func, Object arg)
 {
     ApplyHelper(null, 0, 0, func, arg);
 }
示例#6
0
文件: Trie.cs 项目: wbj808178/netmq
 //  Apply the function supplied to each subscription in the trie.
 public void Apply(TrieDelegate func, Object arg)
 {
     ApplyHelper(null, 0, 0, func, arg);
 }
示例#7
0
文件: Trie.cs 项目: awb99/netmq
        private void ApplyHelper( byte[] buffer, int bufferSize, int maxBufferSize,  TrieDelegate func,  object arg)
        {
            // If this node is a subscription, apply the function.
            if (m_referenceCount > 0)
                func(buffer, bufferSize, arg);

            // Adjust the buffer.
            if (bufferSize >= maxBufferSize)
            {
                maxBufferSize = bufferSize + 256;
                Array.Resize(ref buffer, maxBufferSize);
                Debug.Assert(buffer != null);
            }

            // If there are no subnodes in the trie, return.
            if (m_count == 0)
                return;

            // If there's one subnode (optimisation).
            if (m_count == 1)
            {
                buffer[bufferSize] = m_minCharacter;
                bufferSize++;
                m_next[0].ApplyHelper(buffer, bufferSize, maxBufferSize, func, arg);
                return;
            }

            // If there are multiple subnodes.
            for (short c = 0; c != m_count; c++)
            {
                buffer[bufferSize] = (byte)(m_minCharacter + c);
                if (m_next[c] != null)
                    m_next[c].ApplyHelper(buffer, bufferSize + 1, maxBufferSize, func, arg);
            }
        }