Ejemplo n.º 1
0
        public bool found(int id)
        {
            var a = store.Accounts[id];

            var key = (long)category << 60
                      | (long)(127 - BitMap96.Common(acct.InterestMask, a.InterestMask)) << 53
                      | (long)(Math.Abs(acct.Birth - a.Birth)) << 21
                      | (long)(id & ((1 << 21) - 1));

            if (Selected.Count < limit)
            {
                Selected.Add(key, id);
            }
            else
            {
                if (lastKey == 0)
                {
                    lastKey = Selected.Keys.Last();
                }

                if (key < lastKey)
                {
                    Selected.Add(key, id);
                    Selected.Remove(lastKey);
                    lastKey = Selected.Keys.Last();
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
 // count out
 public void Exclude(int location, int status, int sex, int year, BitMap96 interestMask)
 {
     Debug.Assert(location >= 0);
     Debug.Assert(status >= 0);
     Debug.Assert(sex >= 0);
     Debug.Assert(year >= 0);
     root.Update(location, status, sex, year, interestMask, -1);
 }
Ejemplo n.º 3
0
 public void Exclude(int location, int status, int sex, int year, BitMap96 interests)
 {
     updateAll(location, status, sex, year, aggInterests, Dec);
     for (int i = 1; i < BitMap96.MAX_BITS; i++)
     {
         if (interests.IsSet(i))
         {
             updateAll(location, status, sex, year, i, Dec);
         }
     }
 }
Ejemplo n.º 4
0
 // clean up before returning to the pool
 public DtoAccount Reset()
 {
     id        = birth = joined = premium.start = premium.finish = 0;
     fnameIdx  = snameIdx = cityIdx = countryIdx = 0;
     phone     = email = AString.Empty;
     status    = 0; sex = false;
     interests = new BitMap96();
     likes.Clear();
     flags = 0;
     return(this);
 }
Ejemplo n.º 5
0
        private int[] interests; // [0] = aggregate

        public void Update(BitMap96 interestMask, int change /*+1 or -1*/)
        {
            if (interests == null)
            {
                interests = new int[BitMap96.MAX_BITS];
            }
            interests[0] += change; // aggregate
            for (int i = 1; i < BitMap96.MAX_BITS; i++)
            {
                if (interestMask.IsSet(i))
                {
                    interests[i] += change;
                }
            }
        }
Ejemplo n.º 6
0
 public void Update(int location, int status, int sex, int year, BitMap96 interestMask, int change /*+1 or -1*/)
 {
     if (locations == null)
     {
         locations = new List <LocationNode>(LocationNode.MAX_LOCATIONS);
         aggregate = new LocationNode();
     }
     while (location >= locations.Count)
     {
         locations.Add(null);
     }
     if (locations[location] == null)
     {
         locations[location] = new LocationNode();
     }
     locations[location].Update(status, sex, year, interestMask, change);
     aggregate.Update(status, sex, year, interestMask, change);
 }
Ejemplo n.º 7
0
 public void Update(int year, BitMap96 interestMask, int change /*+1 or -1*/)
 {
     if (years == null)
     {
         years     = new List <YearNode>(YearNode.MAX_YEARS);
         aggregate = new YearNode();
     }
     while (year >= years.Count)
     {
         years.Add(null);
     }
     if (years[year] == null)
     {
         years[year] = new YearNode();
     }
     years[year].Update(interestMask, change);
     aggregate.Update(interestMask, change);
 }
Ejemplo n.º 8
0
 public void Update(int sex, int year, BitMap96 interestMask, int change /*+1 or -1*/)
 {
     if (sexes == null)
     {
         sexes     = new List <SexNode>(SexNode.MAX_SEXES);
         aggregate = new SexNode();
     }
     while (sex >= sexes.Count)
     {
         sexes.Add(null);
     }
     if (sexes[sex] == null)
     {
         sexes[sex] = new SexNode();
     }
     sexes[sex].Update(year, interestMask, change);
     aggregate.Update(year, interestMask, change);
 }
Ejemplo n.º 9
0
 public void Update(int status, int sex, int year, BitMap96 interestMask, int change /*+1 or -1*/)
 {
     if (statuses == null)
     {
         statuses  = new List <StatusNode>(StatusNode.MAX_STATUSES);
         aggregate = new StatusNode();
     }
     while (status >= statuses.Count)
     {
         statuses.Add(null);
     }
     if (statuses[status] == null)
     {
         statuses[status] = new StatusNode();
     }
     statuses[status].Update(sex, year, interestMask, change);
     aggregate.Update(sex, year, interestMask, change);
 }
Ejemplo n.º 10
0
 // union with another bitmask
 public void Or(BitMap96 other)
 {
     high |= other.high;
     low  |= other.low;
 }
Ejemplo n.º 11
0
 // intersect with another bitmask
 public void And(BitMap96 other)
 {
     high &= other.high;
     low  &= other.low;
 }
Ejemplo n.º 12
0
 public bool Any(BitMap96 from)
 {
     return(unchecked ((high & from.high) + ((long)low & (long)from.low) != 0));
 }
Ejemplo n.º 13
0
 // all bits from the other bitmask are present
 public bool All(BitMap96 from)
 {
     return((high & from.high) == from.high &&
            (low & from.low) == from.low);
 }