Skip to content

Instantly share code, notes, and snippets.

View fulmicoton's full-sized avatar
🤪

Paul Masurel fulmicoton

🤪
View GitHub Profile
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<_>>();
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)
}
}
def fibo(n = 10):
els = []
prev = 1
next = 1
for i in range(n):
(prev, next) = (next, prev+next)
els.append(prev)
return els
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
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 ...
extern crate scoped_pool;
use std::thread;
use std::sync::Arc;
fn main() {
println!("a");
let pool = Arc::new(scoped_pool::Pool::new(2));
#![feature(test)]
extern crate test;
#[macro_use]
extern crate lazy_static;
#[cfg(test)]
mod tests {
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
from collections import defaultdict
class StateMachine:
def initial_state(self):
raise NotImplementError()
def accept(self, state):
raise NotImplementError()
#[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]>,
}