private static void AddNode(ref FanoutPathDescriptor desc, int hop, long id) { switch (hop) { case 0: throw new NotImplementedException(); case 1: desc.hop_1 = id; break; case 2: desc.hop_2 = id; break; case 3: desc.hop_3 = id; break; default: if (desc.hop_n == null) { desc.hop_n = new List <long>(); } desc.hop_n.Add(id); break; } }
/// <summary> /// Caller should guarantee that path has sufficient storage space. No check on path.hop_n /// </summary> private void SetCellIdInPath(ref FanoutPathDescriptor path, int hop, long id) { switch (hop) { case 0: path.hop_0 = id; break; case 1: path.hop_1 = id; break; case 2: path.hop_2 = id; break; case 3: path.hop_3 = id; break; default: path.hop_n[hop - 4] = id; break; } }
private unsafe FanoutPathDescriptor GetPathDescriptor(long *ptr, int hop) { FanoutPathDescriptor path = new FanoutPathDescriptor(); if (hop > 3) { path.hop_n = new List <long>(Enumerable.Repeat(0L, hop - 3)); } for (int i = 0; i <= hop; ++i) { SetCellIdInPath(ref path, i, ptr[i]); } return(path); }
private long GetCellIdInPath(FanoutPathDescriptor path, int hop) { switch (hop) { case 0: return(path.hop_0); case 1: return(path.hop_1.Value); case 2: return(path.hop_2.Value); case 3: return(path.hop_3.Value); default: return(path.hop_n[hop - 4]); } }