Sketch A is either unordered compact or hash table
174799
private void scanAllAsearchB() {
    final long[] scanAArr = a_.getCache();
    final int arrLongsIn = scanAArr.length;
    cache_ = new long[arrLongsIn];
    for (int i = 0; i < arrLongsIn; i++ ) {
      final long hashIn = scanAArr[i];
      if ((hashIn <= 0L) || (hashIn >= thetaLong_)) { continue; }
      final int foundIdx = hashSearch(bHashTable_, lgArrLongsHT_, hashIn);
      if (foundIdx > -1) { continue; }
      cache_[curCount_++] = hashIn;
    }
  }
1037768
function hashcons(node) {
  const keys = t.VISITOR_KEYS[node.type];
  if (!keys) return;

  let hash = hashcode(node);

  for (const key of keys) {
    const subNode = node[key];

    if (Array.isArray(subNode)) {
      for (const child of subNode) {
        if (child) {
          hash += hashcons(child);
        }
      }
    } else if (subNode) {
      hash += hashcons(subNode);
    }
  }

  return hash;
}
568375
private PageLeafImpl compact(TableKelp table)
  {
    long now = CurrentTime.currentTime() / 1000;
    
    Set<PageLeafEntry> entries = fillEntries(table);
    
    ArrayList<BlockLeaf> blocks = new ArrayList<>();
    BlockLeaf block = new BlockLeaf(getId());
    
    blocks.add(block);
    
    Row row = table.row();
    
    for (PageLeafEntry entry : entries) {
      if (entry.getCode() != INSERT && entry.getExpires() <= now) {
        continue;
      }

      while (! block.addEntry(row, entry)) {
        block = new BlockLeaf(getId());
        blocks.add(block);
      }
    }
    
    PageLeafImpl newPage = new PageLeafImpl(getId(), 
                                            getNextId(), 
                                            getSequence(),
                                            _table,
                                            getMinKey(), 
                                            getMaxKey(),
                                            blocks);
    
    newPage.validate(table);
    newPage.toSorted(table);
    
    if (isDirty()) {
      newPage.setDirty();
    }
    
    if (_stub != null) {
      _stub.copyToCompact(newPage);
    }

    return newPage;
  }
1265478
def hash_to_condition(table, hash)
      conditions = hash.map do |attr, value|
        if value.is_a?(Array) && value.size > 1
          table[attr].in(value)
        elsif value.is_a?(Array)
          table[attr].eq(value[0])
        else
          table[attr].eq(value)
        end
      end

      conditions.reduce { |memo, cond| memo.and(cond) }
    end
1306455
static <T> ItemsSketch<T> copy(final ItemsSketch<T> sketch) {
    final ItemsSketch<T> qsCopy = ItemsSketch.getInstance(sketch.k_, sketch.comparator_);
    qsCopy.n_ = sketch.n_;
    qsCopy.minValue_ = sketch.getMinValue();
    qsCopy.maxValue_ = sketch.getMaxValue();
    qsCopy.combinedBufferItemCapacity_ = sketch.getCombinedBufferAllocatedCount();
    qsCopy.baseBufferCount_ = sketch.getBaseBufferCount();
    qsCopy.bitPattern_ = sketch.getBitPattern();
    final Object[] combBuf = sketch.getCombinedBuffer();
    qsCopy.combinedBuffer_ = Arrays.copyOf(combBuf, combBuf.length);
    return qsCopy;
  }
1197632
function compactSparseArray (array) {
        var index = -1,
            length = array ? array.length : 0,
            result = [];

        while (++index < length) {
            var value = array[index];

            if (value) {
                result.push(value);
            }
        }

        return result;
    }
613036
def compact_of(values = {}, path = KeyPath.new)
        result = {}
        values.each_with_index do |(i, v)|
          path.move_to(i)
          if v.is_a?(Hash)
            result.merge!(compact_of(v, path))
          else
            result[path.to_s] = v
          end
          path.leave
        end
        result
      end
950148
@SuppressWarnings("unchecked")
  public CompactSketch<S> compact() {
    if (getRetainedEntries() == 0) {
      return new CompactSketch<>(null, null, theta_, isEmpty_);
    }
    final long[] keys = new long[getRetainedEntries()];
    final S[] summaries = (S[])
      Array.newInstance(summaries_.getClass().getComponentType(), getRetainedEntries());
    int i = 0;
    for (int j = 0; j < keys_.length; j++) {
      if (summaries_[j] != null) {
        keys[i] = keys_[j];
        summaries[i] = (S)summaries_[j].copy();
        i++;
      }
    }
    return new CompactSketch<>(keys, summaries, theta_, isEmpty_);
  }
557305
function compactTree(metadata) {
  var revs = [];
  traverseRevTree(metadata.rev_tree, function (isLeaf, pos,
                                               revHash, ctx, opts) {
    if (opts.status === 'available' && !isLeaf) {
      revs.push(pos + '-' + revHash);
      opts.status = 'missing';
    }
  });
  return revs;
}
702493
function getHashesFromRoute(route, depth, hashes, hash) {
    /*eslint-disable no-func-assign, no-param-reassign*/
    depth = depth || 0;
    hashes = hashes || [];
    hash = hash || [];
    /*eslint-enable no-func-assign, no-param-reassign*/

    var routeValue = route[depth];
    var isArray = Array.isArray(routeValue);
    var length = isArray && routeValue.length || 0;
    var idx = 0;
    var value;

    if (typeof routeValue === 'object' && !isArray) {
        value = routeValue.type;
    }

    else if (!isArray) {
        value = routeValue;
    }

    do {
        if (isArray) {
            value = routeValue[idx];
        }

        if (value === Keys.integers || value === Keys.ranges) {
            hash[depth] = '__I__';
        }

        else if (value === Keys.keys) {
            hash[depth] ='__K__';
        }

        else {
            hash[depth] = value;
        }

        // recurse down the routed token
        if (depth + 1 !== route.length) {
            getHashesFromRoute(route, depth + 1, hashes, hash);
        }

        // Or just add it to hashes
        else {
            hashes.push(cloneArray(hash));
        }
    } while (isArray && ++idx < length);

    return hashes;
}
574692
public void update(final ArrayOfDoublesSketch sketchIn, final ArrayOfDoublesCombiner combiner) {
    final boolean isFirstCall = isFirstCall_;
    isFirstCall_ = false;
    if (sketchIn == null) {
      isEmpty_ = true;
      sketch_ = null;
      return;
    }
    Util.checkSeedHashes(seedHash_, sketchIn.getSeedHash());
    theta_ = min(theta_, sketchIn.getThetaLong());
    isEmpty_ |= sketchIn.isEmpty();
    if (isEmpty_ || sketchIn.getRetainedEntries() == 0) {
      sketch_ = null;
      return;
    }
    if (isFirstCall) {
      sketch_ = createSketch(sketchIn.getRetainedEntries(), numValues_, seed_);
      final ArrayOfDoublesSketchIterator it = sketchIn.iterator();
      while (it.next()) {
        sketch_.insert(it.getKey(), it.getValues());
      }
    } else { //not the first call
      final int matchSize = min(sketch_.getRetainedEntries(), sketchIn.getRetainedEntries());
      final long[] matchKeys = new long[matchSize];
      final double[][] matchValues = new double[matchSize][];
      int matchCount = 0;
      final ArrayOfDoublesSketchIterator it = sketchIn.iterator();
      while (it.next()) {
        final double[] values = sketch_.find(it.getKey());
        if (values != null) {
          matchKeys[matchCount] = it.getKey();
          matchValues[matchCount] = combiner.combine(values, it.getValues());
          matchCount++;
        }
      }
      sketch_ = null;
      if (matchCount > 0) {
        sketch_ = createSketch(matchCount, numValues_, seed_);
        for (int i = 0; i < matchCount; i++) {
          sketch_.insert(matchKeys[i], matchValues[i]);
        }
      }
      if (sketch_ != null) {
        sketch_.setThetaLong(theta_);
        sketch_.setNotEmpty();
      }
    }
  }
740518
def _generate_hash(self, lista):
        
        hash_elements = defaultdict(list)

        for element in lista:
            key = self.similarity_key(element)
            hash_elements[key].append(element)

        return hash_elements
812719
def shrink(self, src, width=0, max_value=0, filter_method=None,
               path=None, flags=0):
        
        if filter_method:
            get_ = _madoka.Sketch_get__
            set_ = _madoka.Sketch_set__
            new_sketch = Sketch(width, max_value, path, flags, src.seed)
            for table_id in range(SKETCH_DEPTH):
                for offset in range(width, src.width, width):
                    for cell_id in range(width):
                        val = get_(src, table_id, offset + cell_id)
                        val = filter_method(val)
                        val = max_value if val > max_value else val
                        if val > get_(new_sketch, table_id, cell_id):
                            set_(new_sketch, table_id, cell_id, val)
            self.swap(new_sketch)
        else:
            _madoka.Sketch_shrink(self, src, width, max_value, None, path, flags)
997912
@SuppressWarnings("unchecked")
  static <T> void processFullBaseBuffer(final ItemsSketch<T> sketch) {
    final int bbCount = sketch.getBaseBufferCount();
    final long n = sketch.getN();
    assert bbCount == (2 * sketch.getK()); // internal consistency check

    // make sure there will be enough levels for the propagation
    ItemsUpdateImpl.maybeGrowLevels(sketch, n); // important: n_ was incremented by update before we got here

    // this aliasing is a bit dangerous; notice that we did it after the possible resizing
    final Object[] baseBuffer = sketch.getCombinedBuffer();

    Arrays.sort((T[]) baseBuffer, 0, bbCount, sketch.getComparator());
    ItemsUpdateImpl.inPlacePropagateCarry(
        0,
        null, 0,  // this null is okay
        (T[]) baseBuffer, 0,
        true, sketch);
    sketch.baseBufferCount_ = 0;
    Arrays.fill(baseBuffer, 0, 2 * sketch.getK(), null); // to release the discarded objects
    assert (n / (2L * sketch.getK())) == sketch.getBitPattern();  // internal consistency check
  }
1211642
int hash(ByteBuffer indices, ByteBuffer vertices, ByteBuffer normals, ByteBuffer colors) {
		int hashCode = 0;
		hashCode += indices.hashCode();
		hashCode += vertices.hashCode();
		hashCode += normals.hashCode();
		hashCode += colors.hashCode();
		
		return hashCode;
	}
1108114
private int hash(GraphicsConfiguration config, int w, int h, Object... args) {
        int hash;

        hash = (config != null ? config.hashCode() : 0);
        hash = 31 * hash + w;
        hash = 31 * hash + h;
        hash = 31 * hash + Arrays.deepHashCode(args);

        return hash;
    }
1102721
function sortedHashKeys(obj, desc) {
		var keys = [];

		for (var key in obj)
			keys.push(key);

		return sort.call(keys, function(a,b) {
			return desc ? obj[b] - obj[a] : obj[a] - obj[b];
		});
	}