changing to STL deque
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
36d098cea3
commit
5faca2220a
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
|
#include "pybind11/pybind11.h"
|
||||||
|
#include "pybind11/stl.h"
|
||||||
|
|
||||||
|
namespace py = pybind11;
|
||||||
|
|
||||||
|
using std::deque;
|
||||||
|
|
||||||
|
struct DequeInt {
|
||||||
|
deque<int16_t> d;
|
||||||
|
DequeInt() {}
|
||||||
|
void push(int e) { d.push_back(e); }
|
||||||
|
int pop() {
|
||||||
|
auto ret = d.front();
|
||||||
|
d.pop_front();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool empty() {return d.empty();}
|
||||||
|
bool notEmpty() {return not d.empty();}
|
||||||
|
};
|
||||||
|
|
||||||
|
PYBIND11_MODULE(deque, m) {
|
||||||
|
// m.doc() = "STL based deque"; // optional module docstring
|
||||||
|
py::class_<DequeInt>(m, "DequeInt")
|
||||||
|
.def(py::init<>())
|
||||||
|
.def("append", &DequeInt::push)
|
||||||
|
.def("popleft", &DequeInt::pop)
|
||||||
|
.def("empty", &DequeInt::empty)
|
||||||
|
.def("__bool__", &DequeInt::notEmpty);
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import collections
|
||||||
import logging
|
import logging
|
||||||
from DAS.block import *
|
from DAS.block import *
|
||||||
from DAS.tools import shuffled, shuffledDict, unionOfSamples
|
from DAS.tools import shuffled, shuffledDict, unionOfSamples
|
||||||
|
from DAS.deque import DequeInt
|
||||||
from bitarray.util import zeros
|
from bitarray.util import zeros
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
@ -28,7 +29,7 @@ class Neighbor:
|
||||||
self.receiving = zeros(blockSize)
|
self.receiving = zeros(blockSize)
|
||||||
self.received = zeros(blockSize)
|
self.received = zeros(blockSize)
|
||||||
self.sent = zeros(blockSize)
|
self.sent = zeros(blockSize)
|
||||||
self.sendQueue = deque()
|
self.sendQueue = DequeInt()
|
||||||
|
|
||||||
|
|
||||||
class Validator:
|
class Validator:
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
.PHONY: test clean
|
||||||
|
|
||||||
|
CC := g++
|
||||||
|
FLAGS := -Wall -std=c++11 -shared -fPIC
|
||||||
|
FLAGS += -undefined dynamic_lookup
|
||||||
|
INC := $(shell python3 -m pybind11 --include)
|
||||||
|
SUFFIX := $(shell python3-config --extension-suffix)
|
||||||
|
|
||||||
|
CC_FILE := DAS/deque.cc
|
||||||
|
OBJ := DAS/deque$(SUFFIX)
|
||||||
|
|
||||||
|
$(OBJ): $(CC_FILE)
|
||||||
|
$(CC) $(FLAGS) $(INC) $< -o $(OBJ)
|
||||||
|
clean:
|
||||||
|
rm *.so
|
Loading…
Reference in New Issue