private bool AddHelper(byte[] prefix, int start, Pipe pipe) { // We are at the node corresponding to the prefix. We are done. if (prefix == null || prefix.Length == start) { bool result = m_pipes == null; if (m_pipes == null) m_pipes = new HashSet<Pipe>(); m_pipes.Add (pipe); return result; } byte c = prefix[start]; if (c < m_min || c >= m_min + m_count) { // The character is out of range of currently handled // charcters. We have to extend the table. if (m_count == 0) { m_min = c; m_count = 1; m_next = null; } else if (m_count == 1) { int oldc = m_min; Mtrie oldp = m_next[0]; m_count = (m_min < c ? c - m_min : m_min - c) + 1; m_next = new Mtrie[m_count]; m_min = Math.Min (m_min, c); m_next[oldc - m_min] = oldp; } else if (m_min < c) { // The new character is above the current character range. m_count = c - m_min + 1; m_next = Realloc(m_next, m_count, true); } else { // The new character is below the current character range. m_count = (m_min + m_count) - c; m_next = Realloc(m_next, m_count, false); m_min = c; } } // If next node does not exist, create one. if (m_count == 1) { if (m_next == null) { m_next = new Mtrie[1]; m_next[0] = new Mtrie(); ++m_liveNodes; //alloc_Debug.Assert(next.node); } return m_next[0].AddHelper (prefix, start + 1, pipe); } else { if (m_next[c - m_min] == null) { m_next[c - m_min] = new Mtrie(); ++m_liveNodes; //alloc_Debug.Assert(next.table [c - min]); } return m_next[c - m_min].AddHelper (prefix , start + 1, pipe); } }
private Mtrie[] Realloc(Mtrie[] table, int size, bool ended) { return Utils.Realloc(table, size, ended); }
public XPub(Ctx parent, int tid, int sid) : base(parent, tid, sid) { m_options.SocketType = ZmqSocketType.Xpub; m_verbose = false; m_more = false; m_subscriptions = new Mtrie(); m_dist = new Dist(); m_pending = new Deque<Blob>(); }