Ejemplo n.º 1
0
        // force construction with make static methods
        /** used for when the ocrrence time will be set later; so should not be called from externally but through another Stamp constructor */
        private Stamp(EnumTense tense, long serial)
        {
            dualStamp = new DualStamp(Parameters.STAMP_NUMBEROFELEMENTS, Parameters.STAMP_BLOOMFILTERNUMBEROFBITS);
            dualStamp.insertAtFront(new List <uint> {
                // HACK< stamps must store long !!! >
                (uint)serial
            });

            this.tense = tense;
        }
Ejemplo n.º 2
0
        public static DualStamp zip(DualStamp a, DualStamp b)
        {
            DualStamp result = new DualStamp(a.numberOfElements, a.bloomfilter.numberOfBits);

            uint newUsed = Math.Min((uint)(a.privateUsed + b.privateUsed), (uint)a.numberOfElements);

            int ai = 0, bi = 0;

            IList <uint> zipped = new List <uint>();

            // zip
            for (;; ai++, bi++)
            {
                if (ai == a.used || bi == b.used)
                {
                    break;
                }

                zipped.Add(a.accessTermIdHistory(ai));
                zipped.Add(b.accessTermIdHistory(bi));
            }

            // remainder
            for (;; ai++)
            {
                if (ai == a.used)
                {
                    break;
                }

                zipped.Add(a.accessTermIdHistory(ai));
            }

            for (; ; bi++)
            {
                if (bi == b.used)
                {
                    break;
                }

                zipped.Add(b.accessTermIdHistory(bi));
            }

            result.insertAtFront(zipped);
            result.recalcBloomfilter(newUsed);
            return(result);
        }