Skip to content

Instantly share code, notes, and snippets.

View spyk's full-sized avatar

Spyros Kapnissis spyk

View GitHub Profile
@spyk
spyk / ModifiedWeightedQuickUnionUF.scala
Last active June 9, 2018 08:07
ModifiedWeightedQuickUnionUF - merge a Set[Set[Int]] in its connected components
class ModifiedWeightedQuickUnionUF(sets: Set[Set[Int]]) {
// The total number of distinct elements
var count: Int = sets.flatten.size
// Map them into an index of (0 to count)
val mapped: Map[Int, Int] = sets.flatten.zipWithIndex.toMap
// Also keep the inverse index (elem -> idx)
val mappedInv: Map[Int, Int] = sets.flatten.zipWithIndex.map(_.swap).toMap
### Keybase proof
I hereby claim:
* I am spyk on github.
* I am skapnissis (https://keybase.io/skapnissis) on keybase.
* I have a public key ASBJYU4wZXiB12S71ioukIgEFU1acpSz5uneVYoZPhHdPAo
To claim this, I am signing this object:
@spyk
spyk / 0_reuse_code.js
Created October 21, 2016 14:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@spyk
spyk / TestCachingTokenFilterStreamApi.java
Created March 22, 2015 22:54
CachingTokenFilter - end() called before incrementToken() returned false!
package org.apache.lucene.analysis;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.