This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |