This file contains hidden or 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 criterion::*; | |
use rand::distributions::Distribution; | |
use std::collections::BinaryHeap; | |
use std::cmp::Reverse; | |
fn top_n_vec_sort(dist_num: usize, n: usize) -> Vec<usize> { | |
let dist = rand::distributions::Uniform::from(100000000..1000000000) | |
.sample_iter(rand::thread_rng()) | |
.take(dist_num); | |
let mut v = dist.collect::<Vec<_>>(); |
This file contains hidden or 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
impl Serialize for MyEnum { | |
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | |
where S: ::serde::Serializer, | |
{ | |
serializer.serialize_u16(self as u16) | |
} | |
} | |
This file contains hidden or 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
def fibo(n = 10): | |
els = [] | |
prev = 1 | |
next = 1 | |
for i in range(n): | |
(prev, next) = (next, prev+next) | |
els.append(prev) | |
return els |
This file contains hidden or 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
Let's call (r_i)_{i>=0} the sequence of the ranks of (A^i)_{i>=0}. | |
For any i>=0, the image of A^{i+1} is a subspace of the image of A^{i}. | |
Our sequence of ranks (r_i) is non-increasing. | |
If for a given i, we have rank of r^i = r^{i+1}, this means that A restricted to the image | |
of {A^i} is bijective. As a result for all j > i, the image of {A^j} is exactly the image of {A^i}. | |
In other words, (r_i) is a sequence of non-negative integers that | |
- starts at n | |
- might be stricly decreasing for a while |
This file contains hidden or 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
So if I understand correctly, you want your docs to be sorted against something like | |
f(textual document content, some field content contains a specific value). | |
You did not make it clear if you were looking for a lexicographical sort | |
f(text, somefield) -> (text, somefield) | |
Or if you wanted to sort by the field | |
f(text, somefield) -> somefield | |
Or if you wanted a best effort solution ... | |
This file contains hidden or 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
extern crate scoped_pool; | |
use std::thread; | |
use std::sync::Arc; | |
fn main() { | |
println!("a"); | |
let pool = Arc::new(scoped_pool::Pool::new(2)); |
This file contains hidden or 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
#![feature(test)] | |
extern crate test; | |
#[macro_use] | |
extern crate lazy_static; | |
#[cfg(test)] | |
mod tests { |
This file contains hidden or 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
mmap(0x0, 0x62000, 0x1, 0x1002, 0xFFFFFFFF, 0x0) = 0x103049000 0 | |
mmap(0x103049000, 0x1000, 0x1, 0x12, 0x3, 0x0) = 0x103049000 0 | |
mmap(0x10304A000, 0x1000, 0x1, 0x12, 0x3, 0x4000) = 0x10304A000 0 | |
mmap(0x10304B000, 0x1000, 0x1, 0x12, 0x3, 0x8000) = 0x10304B000 0 | |
mmap(0x10304C000, 0x1000, 0x1, 0x12, 0x3, 0xC000) = 0x10304C000 0 | |
mmap(0x10304D000, 0x1000, 0x1, 0x12, 0x3, 0x10000) = 0x10304D000 0 | |
mmap(0x10304E000, 0x1000, 0x1, 0x12, 0x3, 0x14000) = 0x10304E000 0 | |
mmap(0x10304F000, 0x1000, 0x1, 0x12, 0x3, 0x18000) = 0x10304F000 0 | |
mmap(0x103050000, 0x1000, 0x1, 0x12, 0x3, 0x1C000) = 0x103050000 0 | |
mmap(0x103051000, 0x1000, 0x1, 0x12, 0x3, 0x20000) = 0x103051000 0 |
This file contains hidden or 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
from collections import defaultdict | |
class StateMachine: | |
def initial_state(self): | |
raise NotImplementError() | |
def accept(self, state): | |
raise NotImplementError() |
This file contains hidden or 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
#[inline(always)] | |
fn most_significant_bit(n: u64) -> usize { | |
use std::intrinsics::ctlz; | |
(63u64 - unsafe {ctlz(n)}) as usize | |
} | |
pub struct PopSet { | |
upper: u64, | |
lower: Box<[u64; 64]>, | |
} |