Skip to content

Instantly share code, notes, and snippets.

View ExpHP's full-sized avatar

Michael Lamparski ExpHP

View GitHub Profile
use std::collections::{HashMap, VecDeque};
use std::hash::Hash;
pub type Count = usize;
/// Ring-buffer based counter for O(1) checking of counts
/// of a value within the last `n` entries.
///
/// Probably overkill.
pub struct RecentCounts<T> {
potential:
supercell: {target: [1, 1, 1]}
kind:
kc-z: {}
#airebo:
# lj-sigma: 3.0
# lj-scale: 1.0
scale-ranges:
repeat-count: 2
parameter:
@ExpHP
ExpHP / is_sorted.rs
Last active February 26, 2018 02:55
definitions of is_sorted
use std::cmp::Ordering;
use std::collections::BTreeSet;
macro_rules! set {
($($t:tt)*) => { vec![$($t)*].into_iter().collect::<BTreeSet<_>>() };
}
/// Implements "is subset of" as a comparator.
struct Subset<S>(BTreeSet<S>);
lattice:
- [2.6457513110645907, 0.0]
- [-1.3228756555322954, 2.29128784747792]
layer:
- frac-lattice:
- [-0.14285714285714285, 0.2857142857142857]
- [-0.2857142857142857, -0.42857142857142855]
frac-sites:
- [0.0, 0.0]
- [0.6666666666666666, 0.3333333333333333]
potential:
supercell: {target: [1, 1, 1]}
kind:
kc-z: {}
#airebo:
# lj-sigma: 3.0
# lj-scale: 1.0
scale-ranges:
repeat-count: 2
parameter:
@ExpHP
ExpHP / compile-fail_auxiliary_macro-comma-support.rs
Created February 7, 2018 18:02
macro-comma-support tests with double comma tests
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
@ExpHP
ExpHP / madness.rs
Created December 12, 2017 22:09
trait bound maaaaadness
use ::std::ops::{Add, Sub, Neg};
pub trait AddSub2<OtherP>
: Sized
+ Add<<Self as AddSub2<OtherP>>::Zero, Output=Self>
+ Sub<<Self as AddSub2<OtherP>>::Zero, Output=Self>
+ Add<<Self as AddSub2<OtherP>>::Other, Output=<Self as AddSub2<OtherP>>::Add>
+ Sub<<Self as AddSub2<OtherP>>::Other, Output=<Self as AddSub2<OtherP>>::Sub>
+ Add<<Self as AddSub2<OtherP>>::NOther, Output=<Self as AddSub2<OtherP>>::Sub>
+ Sub<<Self as AddSub2<OtherP>>::NOther, Output=<Self as AddSub2<OtherP>>::Add>
pub use ::std::io::prelude::*;
pub use ::std::io::Result;
pub trait Node
: Copy + Ord + Eq
{
fn add(self, b: Self) -> Self;
fn sub(self, b: Self) -> Self;
fn neg(self) -> Self;
@ExpHP
ExpHP / madness.rs
Last active December 12, 2017 23:16
use ::std::ops::{Add, Sub, Neg};
pub trait AddSub2<OtherP>
: Sized
+ Add<<Self as AddSub2<OtherP>>::Zero, Output=Self>
+ Sub<<Self as AddSub2<OtherP>>::Zero, Output=Self>
+ Add<<Self as AddSub2<OtherP>>::Other, Output=<Self as AddSub2<OtherP>>::Add>
+ Sub<<Self as AddSub2<OtherP>>::Other, Output=<Self as AddSub2<OtherP>>::Sub>
+ Add<<Self as AddSub2<OtherP>>::NOther, Output=<Self as AddSub2<OtherP>>::Sub>
+ Sub<<Self as AddSub2<OtherP>>::NOther, Output=<Self as AddSub2<OtherP>>::Add>
use ::std::ops::{Add, Sub, Neg};
pub trait AddSub1
: Sized
+ Add<<Self as AddSub1>::NThrice, Output=<Self as AddSub1>::NTwice>
+ Sub<<Self as AddSub1>::NThrice>
+ Add<<Self as AddSub1>::NTwice, Output=<Self as AddSub1>::Neg>
+ Sub<<Self as AddSub1>::NTwice, Output=<Self as AddSub1>::Thrice>
+ Add<<Self as AddSub1>::Neg, Output=<Self as AddSub1>::Zero>
+ Sub<<Self as AddSub1>::Neg, Output=<Self as AddSub1>::Twice>