Skip to content

Instantly share code, notes, and snippets.

#include <vector>
struct Node
{
bool accessible;
int x;
int y;
int dx;
int dy;
std::vector<size_t> out_nodes;
#include <unordered_set>
#include <iostream>
struct moo{int i;};
int main(int,char**){
moo * m = new moo();
m->i = 8;
std::unordered_set<moo*> my_set;
my_set.insert(m);
std::cout << "Avant " << m->i;
std::unordered_set<moo*>::const_iterator it = my_set.find(m);
#include <geos_c.h>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
static void notice(const char *fmt, ...)
{
std::fprintf( stdout, "NOTICE: ");
va_list ap;
@Tristramg
Tristramg / bleuarg.cc
Created September 7, 2012 12:49
bleuarrrrggggg
for(const StopArea & sa : this->stop_areas){
for(idx_t sp1_idx : sa.stop_point_list){
for(idx_t sp2_idx : sa.stop_point_list){
for(idx_t rp1_idx : stop_points[sp1_idx].route_point_list){
for(idx_t rp2_idx : stop_points[sp2_idx].route_point_list){
if(rp1_idx < rp2_idx){
boost::tie(e, inserted) = boost::add_edge(rp1_idx, rp2_idx, g);
if(inserted){
weightmap[e] = (sp1_idx == sp2_idx ? Edge(120, eStopPoint) : Edge(180, eStopArea));
}
#include <iostream>
int main()
{
auto f = [](){
int a = 1;
return [a](int x){return a + x;};
};
auto test = f();
#include <memory>
#include <iostream>
int main(int, char**){
std::unique_ptr<int> x(new int(42));
auto y = std::move(x);
auto y = x; // compile pas : use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = int, _Dp = std::default_delete<int>, std::unique_ptr<_Tp, _Dp> = std::unique_ptr<int>]’
std::cout << *x << std::endl;
}
extern mod core;
use core::hashmap::HashMap;
use core::hashmap::linear_map_with_capacity;
// #[crate_type = "lib"];
trait Graph<Node, Edge> {
fn children(&self, Node, &fn(&(Edge, Node)) -> bool); // iterate on outgoing edges
}
extern mod core;
use core::hash::Hash;
use core::hashmap::HashMap;
use core::hashmap::linear_map_with_capacity;
// #[crate_type = "lib"];
trait Graph<Node, Edge> {
fn children(&self, &Node, &fn(&(Node, Edge)) -> bool); // iterate on outgoing edges
@Tristramg
Tristramg / gist:5543989
Created May 8, 2013 21:59
src/graph.rs:18:28: 18:35 error: mismatched types: expected `&&'a` but found `&'a` (expected &-ptr but found type parameter) src/graph.rs:18 if !visited.get(&target) { ^~~~~~~ src/graph.rs:18:16: 18:38 error: failed to find an implementation of trait core::to_bytes::IterBytes for 'a src/graph.rs:18 if !visited.get(&target) { ^~~~~~~~~~~~~~~~~~~~~~
extern mod core;
use core::hash::Hash;
use core::hashmap::HashMap;
// #[crate_type = "lib"];
trait Graph<Node, Edge> {
fn children(&self, &Node, &fn(&Node, &Edge) -> bool); // iterate on outgoing edges
fn add_node(&mut self, Node);
Traceback (most recent call last):
File "/home/tristram/workspace/siel/top_block.py", line 178, in <module>
tb = top_block()
File "/home/tristram/workspace/siel/top_block.py", line 138, in __init__
self.connect((self.band_pass_filter_1, 0), (self.gr_rds_freq_divider_0, 0))
File "/usr/local/lib/python2.7/dist-packages/gnuradio/gr/top_block.py", line 130, in connect
self._connect(points[i-1], points[i])
File "/usr/local/lib/python2.7/dist-packages/gnuradio/gr/top_block.py", line 142, in _connect
dst_block.to_basic_block(), dst_port)
File "/usr/local/lib/python2.7/dist-packages/gnuradio/gr/runtime_swig.py", line 4238, in primitive_connect