Esempio n. 1
0
        public unsafe static bool SaveSSSPCell(this Trinity.Storage.MemoryCloud storage, long CellID, int distance = default(int), long parent = default(long), List <long> neighbors = null)
        {
            byte *targetPtr = null;

            targetPtr += 4;
            targetPtr += 8;

            if (neighbors != null)
            {
                targetPtr += neighbors.Count * 8 + sizeof(int);
            }
            else
            {
                targetPtr += sizeof(int);
            }


            byte[] tmpcell = new byte[(int)(targetPtr)];
            fixed(byte *tmpcellptr = tmpcell)
            {
                targetPtr          = tmpcellptr;
                *(int *)targetPtr  = distance;
                targetPtr         += 4;
                *(long *)targetPtr = parent;
                targetPtr         += 8;

                if (neighbors != null)
                {
                    *(int *)targetPtr = neighbors.Count * 8;
                    targetPtr        += sizeof(int);
                    for (int iterator_0 = 0; iterator_0 < neighbors.Count; ++iterator_0)
                    {
                        *(long *)targetPtr = neighbors[iterator_0];
                        targetPtr         += 8;
                    }
                }
                else
                {
                    *(int *)targetPtr = 0;
                    targetPtr        += sizeof(int);
                }
            }

            return(storage.SaveCell(CellID, tmpcell, (ushort)CellType.SSSPCell));
        }
Esempio n. 2
0
        public unsafe static bool Savenode(this Trinity.Storage.MemoryCloud storage, long CellID, string name = null, List <long> friends = null)
        {
            byte *targetPtr = null;

            if (name != null)
            {
                targetPtr += name.Length * 2 + sizeof(int);
            }
            else
            {
                targetPtr += sizeof(int);
            }

            if (friends != null)
            {
                targetPtr += friends.Count * 8 + sizeof(int);
            }
            else
            {
                targetPtr += sizeof(int);
            }


            byte[] tmpcell = new byte[(int)(targetPtr)];
            fixed(byte *tmpcellptr = tmpcell)
            {
                targetPtr = tmpcellptr;

                if (name != null)
                {
                    *(int *)targetPtr = name.Length * 2;
                    targetPtr        += sizeof(int);
                    for (int iterator_0 = 0; iterator_0 < name.Length; ++iterator_0)
                    {
                        *(char *)targetPtr = name[iterator_0];
                        targetPtr         += 2;
                    }
                }
                else
                {
                    *(int *)targetPtr = 0;
                    targetPtr        += sizeof(int);
                }

                if (friends != null)
                {
                    *(int *)targetPtr = friends.Count * 8;
                    targetPtr        += sizeof(int);
                    for (int iterator_0 = 0; iterator_0 < friends.Count; ++iterator_0)
                    {
                        *(long *)targetPtr = friends[iterator_0];
                        targetPtr         += 8;
                    }
                }
                else
                {
                    *(int *)targetPtr = 0;
                    targetPtr        += sizeof(int);
                }
            }

            return(storage.SaveCell(CellID, tmpcell, (ushort)CellType.node));
        }