1 /* Generated by Cython 0.17.4 on Sun Feb 24 19:48:34 2013 */
3 #define PY_SSIZE_T_CLEAN
6 #error Python headers needed to compile C extensions, please install development version of Python.
7 #elif PY_VERSION_HEX < 0x02040000
8 #error Cython requires Python 2.4+.
10 #include <stddef.h> /* For offsetof */
12 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
14 #if !defined(WIN32) && !defined(MS_WINDOWS)
26 #define DL_IMPORT(t) t
29 #define DL_EXPORT(t) t
32 #define PY_LONG_LONG LONG_LONG
35 #define Py_HUGE_VAL HUGE_VAL
38 #define CYTHON_COMPILING_IN_PYPY 1
39 #define CYTHON_COMPILING_IN_CPYTHON 0
41 #define CYTHON_COMPILING_IN_PYPY 0
42 #define CYTHON_COMPILING_IN_CPYTHON 1
44 #if PY_VERSION_HEX < 0x02050000
45 typedef int Py_ssize_t;
46 #define PY_SSIZE_T_MAX INT_MAX
47 #define PY_SSIZE_T_MIN INT_MIN
48 #define PY_FORMAT_SIZE_T ""
49 #define CYTHON_FORMAT_SSIZE_T ""
50 #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
51 #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o)
52 #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
53 (PyErr_Format(PyExc_TypeError, \
54 "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
56 #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
58 #define PyIndex_Check __Pyx_PyIndex_Check
59 #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
60 #define __PYX_BUILD_PY_SSIZE_T "i"
62 #define __PYX_BUILD_PY_SSIZE_T "n"
63 #define CYTHON_FORMAT_SSIZE_T "z"
64 #define __Pyx_PyIndex_Check PyIndex_Check
66 #if PY_VERSION_HEX < 0x02060000
67 #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
68 #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
69 #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
70 #define PyVarObject_HEAD_INIT(type, size) \
71 PyObject_HEAD_INIT(type) size,
72 #define PyType_Modified(t)
83 Py_ssize_t *suboffsets;
86 #define PyBUF_SIMPLE 0
87 #define PyBUF_WRITABLE 0x0001
88 #define PyBUF_FORMAT 0x0004
89 #define PyBUF_ND 0x0008
90 #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
91 #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
92 #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
93 #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
94 #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
95 #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
96 #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
97 typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
98 typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
100 #if PY_MAJOR_VERSION < 3
101 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
102 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
103 PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
105 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
106 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
107 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
109 #if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6
110 #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
112 #if PY_MAJOR_VERSION >= 3
113 #define Py_TPFLAGS_CHECKTYPES 0
114 #define Py_TPFLAGS_HAVE_INDEX 0
116 #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
117 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
119 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
120 #define CYTHON_PEP393_ENABLED 1
121 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \
122 0 : _PyUnicode_Ready((PyObject *)(op)))
123 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
124 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
125 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
127 #define CYTHON_PEP393_ENABLED 0
128 #define __Pyx_PyUnicode_READY(op) (0)
129 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
130 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
131 #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
133 #if PY_MAJOR_VERSION >= 3
134 #define PyBaseString_Type PyUnicode_Type
135 #define PyStringObject PyUnicodeObject
136 #define PyString_Type PyUnicode_Type
137 #define PyString_Check PyUnicode_Check
138 #define PyString_CheckExact PyUnicode_CheckExact
140 #if PY_VERSION_HEX < 0x02060000
141 #define PyBytesObject PyStringObject
142 #define PyBytes_Type PyString_Type
143 #define PyBytes_Check PyString_Check
144 #define PyBytes_CheckExact PyString_CheckExact
145 #define PyBytes_FromString PyString_FromString
146 #define PyBytes_FromStringAndSize PyString_FromStringAndSize
147 #define PyBytes_FromFormat PyString_FromFormat
148 #define PyBytes_DecodeEscape PyString_DecodeEscape
149 #define PyBytes_AsString PyString_AsString
150 #define PyBytes_AsStringAndSize PyString_AsStringAndSize
151 #define PyBytes_Size PyString_Size
152 #define PyBytes_AS_STRING PyString_AS_STRING
153 #define PyBytes_GET_SIZE PyString_GET_SIZE
154 #define PyBytes_Repr PyString_Repr
155 #define PyBytes_Concat PyString_Concat
156 #define PyBytes_ConcatAndDel PyString_ConcatAndDel
158 #if PY_VERSION_HEX < 0x02060000
159 #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type)
160 #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type)
162 #ifndef PySet_CheckExact
163 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
165 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
166 #if PY_MAJOR_VERSION >= 3
167 #define PyIntObject PyLongObject
168 #define PyInt_Type PyLong_Type
169 #define PyInt_Check(op) PyLong_Check(op)
170 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
171 #define PyInt_FromString PyLong_FromString
172 #define PyInt_FromUnicode PyLong_FromUnicode
173 #define PyInt_FromLong PyLong_FromLong
174 #define PyInt_FromSize_t PyLong_FromSize_t
175 #define PyInt_FromSsize_t PyLong_FromSsize_t
176 #define PyInt_AsLong PyLong_AsLong
177 #define PyInt_AS_LONG PyLong_AS_LONG
178 #define PyInt_AsSsize_t PyLong_AsSsize_t
179 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
180 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
182 #if PY_MAJOR_VERSION >= 3
183 #define PyBoolObject PyLongObject
185 #if PY_VERSION_HEX < 0x03020000
186 typedef long Py_hash_t;
187 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
188 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
190 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
191 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
193 #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
194 #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
195 #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
196 #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
198 #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
199 (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
200 (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
201 (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
202 #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
203 (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
204 (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
205 (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
206 #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
207 (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
208 (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
209 (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
211 #if PY_MAJOR_VERSION >= 3
212 #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
214 #if PY_VERSION_HEX < 0x02050000
215 #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n)))
216 #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
217 #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n)))
219 #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n))
220 #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
221 #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n))
223 #if PY_VERSION_HEX < 0x02050000
224 #define __Pyx_NAMESTR(n) ((char *)(n))
225 #define __Pyx_DOCSTR(n) ((char *)(n))
227 #define __Pyx_NAMESTR(n) (n)
228 #define __Pyx_DOCSTR(n) (n)
232 #if PY_MAJOR_VERSION >= 3
233 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
234 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
236 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
237 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
240 #ifndef __PYX_EXTERN_C
242 #define __PYX_EXTERN_C extern "C"
244 #define __PYX_EXTERN_C extern
248 #if defined(WIN32) || defined(MS_WINDOWS)
249 #define _USE_MATH_DEFINES
252 #define __PYX_HAVE__bintrees__cwalker
253 #define __PYX_HAVE_API__bintrees__cwalker
260 #ifdef PYREX_WITHOUT_ASSERTIONS
261 #define CYTHON_WITHOUT_ASSERTIONS
265 /* inline attribute */
266 #ifndef CYTHON_INLINE
267 #if defined(__GNUC__)
268 #define CYTHON_INLINE __inline__
269 #elif defined(_MSC_VER)
270 #define CYTHON_INLINE __inline
271 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
272 #define CYTHON_INLINE inline
274 #define CYTHON_INLINE
278 /* unused attribute */
279 #ifndef CYTHON_UNUSED
280 # if defined(__GNUC__)
281 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
282 # define CYTHON_UNUSED __attribute__ ((__unused__))
284 # define CYTHON_UNUSED
286 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
287 # define CYTHON_UNUSED __attribute__ ((__unused__))
289 # define CYTHON_UNUSED
293 typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
296 /* Type Conversion Predeclarations */
298 #define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
299 #define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s))
301 #define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
302 #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
303 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
304 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
306 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
307 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
308 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
310 #if CYTHON_COMPILING_IN_CPYTHON
311 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
313 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
315 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
318 /* Test for GCC > 2.95 */
319 #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
320 #define likely(x) __builtin_expect(!!(x), 1)
321 #define unlikely(x) __builtin_expect(!!(x), 0)
322 #else /* __GNUC__ > 2 ... */
323 #define likely(x) (x)
324 #define unlikely(x) (x)
325 #endif /* __GNUC__ > 2 ... */
327 #define likely(x) (x)
328 #define unlikely(x) (x)
329 #endif /* __GNUC__ */
331 static PyObject *__pyx_m;
332 static PyObject *__pyx_b;
333 static PyObject *__pyx_empty_tuple;
334 static PyObject *__pyx_empty_bytes;
335 static int __pyx_lineno;
336 static int __pyx_clineno = 0;
337 static const char * __pyx_cfilenm= __FILE__;
338 static const char *__pyx_filename;
341 static const char *__pyx_f[] = {
345 /*--- Type declarations ---*/
346 struct __pyx_obj_8bintrees_7cwalker_cWalker;
348 /* "bintrees\cwalker.pxd":11
349 * from stack cimport node_stack_t
351 * cdef class cWalker: # <<<<<<<<<<<<<<
355 struct __pyx_obj_8bintrees_7cwalker_cWalker {
357 struct __pyx_vtabstruct_8bintrees_7cwalker_cWalker *__pyx_vtab;
365 /* "bintrees\cwalker.pyx":14
366 * from ctrees cimport *
368 * cdef class cWalker: # <<<<<<<<<<<<<<
369 * def __cinit__(self):
373 struct __pyx_vtabstruct_8bintrees_7cwalker_cWalker {
374 void (*set_tree)(struct __pyx_obj_8bintrees_7cwalker_cWalker *, node_t *);
375 PyObject *(*reset)(struct __pyx_obj_8bintrees_7cwalker_cWalker *, int __pyx_skip_dispatch);
376 PyObject *(*push)(struct __pyx_obj_8bintrees_7cwalker_cWalker *, int __pyx_skip_dispatch);
377 PyObject *(*pop)(struct __pyx_obj_8bintrees_7cwalker_cWalker *, int __pyx_skip_dispatch);
379 static struct __pyx_vtabstruct_8bintrees_7cwalker_cWalker *__pyx_vtabptr_8bintrees_7cwalker_cWalker;
380 #ifndef CYTHON_REFNANNY
381 #define CYTHON_REFNANNY 0
385 void (*INCREF)(void*, PyObject*, int);
386 void (*DECREF)(void*, PyObject*, int);
387 void (*GOTREF)(void*, PyObject*, int);
388 void (*GIVEREF)(void*, PyObject*, int);
389 void* (*SetupContext)(const char*, int, const char*);
390 void (*FinishContext)(void**);
391 } __Pyx_RefNannyAPIStruct;
392 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
393 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
394 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
396 #define __Pyx_RefNannySetupContext(name, acquire_gil) \
398 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
399 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
400 PyGILState_Release(__pyx_gilstate_save); \
402 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
405 #define __Pyx_RefNannySetupContext(name, acquire_gil) \
406 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
408 #define __Pyx_RefNannyFinishContext() \
409 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
410 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
411 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
412 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
413 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
414 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
415 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
416 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
417 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
419 #define __Pyx_RefNannyDeclarations
420 #define __Pyx_RefNannySetupContext(name, acquire_gil)
421 #define __Pyx_RefNannyFinishContext()
422 #define __Pyx_INCREF(r) Py_INCREF(r)
423 #define __Pyx_DECREF(r) Py_DECREF(r)
424 #define __Pyx_GOTREF(r)
425 #define __Pyx_GIVEREF(r)
426 #define __Pyx_XINCREF(r) Py_XINCREF(r)
427 #define __Pyx_XDECREF(r) Py_XDECREF(r)
428 #define __Pyx_XGOTREF(r)
429 #define __Pyx_XGIVEREF(r)
430 #endif /* CYTHON_REFNANNY */
431 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
432 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
434 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
436 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
437 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
439 static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/
441 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
442 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
444 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
446 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
448 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
450 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
452 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
454 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
456 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
458 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
460 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
462 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
464 static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
466 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
468 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
470 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
472 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
474 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
476 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
478 static void __Pyx_WriteUnraisable(const char *name, int clineno,
479 int lineno, const char *filename); /*proto*/
481 static int __Pyx_check_binary_version(void);
483 static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
487 PyCodeObject* code_object;
488 } __Pyx_CodeObjectCacheEntry;
489 struct __Pyx_CodeObjectCache {
492 __Pyx_CodeObjectCacheEntry* entries;
494 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
495 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
496 static PyCodeObject *__pyx_find_code_object(int code_line);
497 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
499 static void __Pyx_AddTraceback(const char *funcname, int c_line,
500 int py_line, const char *filename); /*proto*/
502 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
505 /* Module declarations from 'bintrees.ctrees' */
507 /* Module declarations from 'bintrees.stack' */
509 /* Module declarations from 'bintrees.cwalker' */
510 static PyTypeObject *__pyx_ptype_8bintrees_7cwalker_cWalker = 0;
511 #define __Pyx_MODULE_NAME "bintrees.cwalker"
512 int __pyx_module_is_main_bintrees__cwalker = 0;
514 /* Implementation of 'bintrees.cwalker' */
515 static PyObject *__pyx_builtin_property;
516 static PyObject *__pyx_builtin_IndexError;
517 static PyObject *__pyx_builtin_KeyError;
518 static int __pyx_pf_8bintrees_7cwalker_7cWalker___cinit__(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
519 static void __pyx_pf_8bintrees_7cwalker_7cWalker_2__dealloc__(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
520 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_4reset(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
521 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_6key(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
522 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_8value(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
523 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_10item(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
524 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_12is_valid(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
525 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_14goto(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
526 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_16push(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
527 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_18pop(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
528 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_20stack_is_empty(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
529 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_22goto_leaf(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
530 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_24has_child(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, int __pyx_v_direction); /* proto */
531 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_26down(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, int __pyx_v_direction); /* proto */
532 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_28go_left(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
533 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_30go_right(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
534 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_32has_left(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
535 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_34has_right(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self); /* proto */
536 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_36succ_item(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
537 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_38prev_item(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
538 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_40floor_item(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
539 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_42ceiling_item(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
540 static char __pyx_k_1[] = "pop(): stack is empty";
541 static char __pyx_k__key[] = "key";
542 static char __pyx_k__pop[] = "pop";
543 static char __pyx_k__item[] = "item";
544 static char __pyx_k__push[] = "push";
545 static char __pyx_k__reset[] = "reset";
546 static char __pyx_k__value[] = "value";
547 static char __pyx_k__KeyError[] = "KeyError";
548 static char __pyx_k____main__[] = "__main__";
549 static char __pyx_k____test__[] = "__test__";
550 static char __pyx_k__is_valid[] = "is_valid";
551 static char __pyx_k__property[] = "property";
552 static char __pyx_k__IndexError[] = "IndexError";
553 static PyObject *__pyx_kp_s_1;
554 static PyObject *__pyx_n_s__IndexError;
555 static PyObject *__pyx_n_s__KeyError;
556 static PyObject *__pyx_n_s____main__;
557 static PyObject *__pyx_n_s____test__;
558 static PyObject *__pyx_n_s__is_valid;
559 static PyObject *__pyx_n_s__item;
560 static PyObject *__pyx_n_s__key;
561 static PyObject *__pyx_n_s__pop;
562 static PyObject *__pyx_n_s__property;
563 static PyObject *__pyx_n_s__push;
564 static PyObject *__pyx_n_s__reset;
565 static PyObject *__pyx_n_s__value;
566 static PyObject *__pyx_k_tuple_2;
569 static int __pyx_pw_8bintrees_7cwalker_7cWalker_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
570 static int __pyx_pw_8bintrees_7cwalker_7cWalker_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
572 __Pyx_RefNannyDeclarations
573 __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
574 if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
575 __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
576 if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
577 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker___cinit__(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
578 __Pyx_RefNannyFinishContext();
582 /* "bintrees\cwalker.pyx":15
584 * cdef class cWalker:
585 * def __cinit__(self): # <<<<<<<<<<<<<<
590 static int __pyx_pf_8bintrees_7cwalker_7cWalker___cinit__(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
592 __Pyx_RefNannyDeclarations
593 __Pyx_RefNannySetupContext("__cinit__", 0);
595 /* "bintrees\cwalker.pyx":16
596 * cdef class cWalker:
597 * def __cinit__(self):
598 * self.root = NULL # <<<<<<<<<<<<<<
600 * self.stack = stack_init(MAXSTACK)
602 __pyx_v_self->root = NULL;
604 /* "bintrees\cwalker.pyx":17
605 * def __cinit__(self):
607 * self.node = NULL # <<<<<<<<<<<<<<
608 * self.stack = stack_init(MAXSTACK)
611 __pyx_v_self->node = NULL;
613 /* "bintrees\cwalker.pyx":18
616 * self.stack = stack_init(MAXSTACK) # <<<<<<<<<<<<<<
618 * def __dealloc__(self):
620 __pyx_v_self->stack = stack_init(32);
623 __Pyx_RefNannyFinishContext();
628 static void __pyx_pw_8bintrees_7cwalker_7cWalker_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
629 static void __pyx_pw_8bintrees_7cwalker_7cWalker_3__dealloc__(PyObject *__pyx_v_self) {
630 __Pyx_RefNannyDeclarations
631 __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
632 __pyx_pf_8bintrees_7cwalker_7cWalker_2__dealloc__(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
633 __Pyx_RefNannyFinishContext();
636 /* "bintrees\cwalker.pyx":20
637 * self.stack = stack_init(MAXSTACK)
639 * def __dealloc__(self): # <<<<<<<<<<<<<<
640 * stack_delete(self.stack)
644 static void __pyx_pf_8bintrees_7cwalker_7cWalker_2__dealloc__(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
645 __Pyx_RefNannyDeclarations
646 __Pyx_RefNannySetupContext("__dealloc__", 0);
648 /* "bintrees\cwalker.pyx":21
650 * def __dealloc__(self):
651 * stack_delete(self.stack) # <<<<<<<<<<<<<<
653 * cdef void set_tree(self, node_t *root):
655 stack_delete(__pyx_v_self->stack);
657 __Pyx_RefNannyFinishContext();
660 /* "bintrees\cwalker.pyx":23
661 * stack_delete(self.stack)
663 * cdef void set_tree(self, node_t *root): # <<<<<<<<<<<<<<
668 static void __pyx_f_8bintrees_7cwalker_7cWalker_set_tree(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, node_t *__pyx_v_root) {
669 __Pyx_RefNannyDeclarations
670 PyObject *__pyx_t_1 = NULL;
671 int __pyx_lineno = 0;
672 const char *__pyx_filename = NULL;
673 int __pyx_clineno = 0;
674 __Pyx_RefNannySetupContext("set_tree", 0);
676 /* "bintrees\cwalker.pyx":24
678 * cdef void set_tree(self, node_t *root):
679 * self.root = root # <<<<<<<<<<<<<<
683 __pyx_v_self->root = __pyx_v_root;
685 /* "bintrees\cwalker.pyx":25
686 * cdef void set_tree(self, node_t *root):
688 * self.reset() # <<<<<<<<<<<<<<
692 __pyx_t_1 = ((struct __pyx_vtabstruct_8bintrees_7cwalker_cWalker *)__pyx_v_self->__pyx_vtab)->reset(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
693 __Pyx_GOTREF(__pyx_t_1);
694 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
698 __Pyx_XDECREF(__pyx_t_1);
699 __Pyx_WriteUnraisable("bintrees.cwalker.cWalker.set_tree", __pyx_clineno, __pyx_lineno, __pyx_filename);
701 __Pyx_RefNannyFinishContext();
704 /* "bintrees\cwalker.pyx":27
707 * cpdef reset(self): # <<<<<<<<<<<<<<
708 * stack_reset(self.stack)
709 * self.node = self.root
712 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_5reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
713 static PyObject *__pyx_f_8bintrees_7cwalker_7cWalker_reset(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, int __pyx_skip_dispatch) {
714 PyObject *__pyx_r = NULL;
715 __Pyx_RefNannyDeclarations
716 PyObject *__pyx_t_1 = NULL;
717 PyObject *__pyx_t_2 = NULL;
719 int __pyx_lineno = 0;
720 const char *__pyx_filename = NULL;
721 int __pyx_clineno = 0;
722 __Pyx_RefNannySetupContext("reset", 0);
723 /* Check if called by wrapper */
724 if (unlikely(__pyx_skip_dispatch)) ;
725 /* Check if overriden in Python */
726 else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
727 __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__reset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
728 __Pyx_GOTREF(__pyx_t_1);
729 if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_5reset)) {
730 __Pyx_XDECREF(__pyx_r);
731 __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
732 __Pyx_GOTREF(__pyx_t_2);
735 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
738 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
741 /* "bintrees\cwalker.pyx":28
744 * stack_reset(self.stack) # <<<<<<<<<<<<<<
745 * self.node = self.root
748 stack_reset(__pyx_v_self->stack);
750 /* "bintrees\cwalker.pyx":29
752 * stack_reset(self.stack)
753 * self.node = self.root # <<<<<<<<<<<<<<
757 __pyx_t_3 = __pyx_v_self->root;
758 __pyx_v_self->node = __pyx_t_3;
760 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
763 __Pyx_XDECREF(__pyx_t_1);
764 __Pyx_XDECREF(__pyx_t_2);
765 __Pyx_AddTraceback("bintrees.cwalker.cWalker.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
768 __Pyx_XGIVEREF(__pyx_r);
769 __Pyx_RefNannyFinishContext();
774 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_5reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
775 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_5reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
776 PyObject *__pyx_r = 0;
777 __Pyx_RefNannyDeclarations
778 __Pyx_RefNannySetupContext("reset (wrapper)", 0);
779 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_4reset(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
780 __Pyx_RefNannyFinishContext();
784 /* "bintrees\cwalker.pyx":27
787 * cpdef reset(self): # <<<<<<<<<<<<<<
788 * stack_reset(self.stack)
789 * self.node = self.root
792 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_4reset(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
793 PyObject *__pyx_r = NULL;
794 __Pyx_RefNannyDeclarations
795 PyObject *__pyx_t_1 = NULL;
796 int __pyx_lineno = 0;
797 const char *__pyx_filename = NULL;
798 int __pyx_clineno = 0;
799 __Pyx_RefNannySetupContext("reset", 0);
800 __Pyx_XDECREF(__pyx_r);
801 __pyx_t_1 = ((struct __pyx_vtabstruct_8bintrees_7cwalker_cWalker *)__pyx_v_self->__pyx_vtab)->reset(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
802 __Pyx_GOTREF(__pyx_t_1);
807 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
810 __Pyx_XDECREF(__pyx_t_1);
811 __Pyx_AddTraceback("bintrees.cwalker.cWalker.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
814 __Pyx_XGIVEREF(__pyx_r);
815 __Pyx_RefNannyFinishContext();
820 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_7key(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
821 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_7key(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
822 PyObject *__pyx_r = 0;
823 __Pyx_RefNannyDeclarations
824 __Pyx_RefNannySetupContext("key (wrapper)", 0);
825 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_6key(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
826 __Pyx_RefNannyFinishContext();
830 /* "bintrees\cwalker.pyx":32
833 * def key(self): # <<<<<<<<<<<<<<
834 * return <object> self.node.key
838 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_6key(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
839 PyObject *__pyx_r = NULL;
840 __Pyx_RefNannyDeclarations
841 __Pyx_RefNannySetupContext("key", 0);
843 /* "bintrees\cwalker.pyx":33
846 * return <object> self.node.key # <<<<<<<<<<<<<<
850 __Pyx_XDECREF(__pyx_r);
851 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->key));
852 __pyx_r = ((PyObject *)__pyx_v_self->node->key);
855 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
857 __Pyx_XGIVEREF(__pyx_r);
858 __Pyx_RefNannyFinishContext();
863 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_9value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
864 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_9value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
865 PyObject *__pyx_r = 0;
866 __Pyx_RefNannyDeclarations
867 __Pyx_RefNannySetupContext("value (wrapper)", 0);
868 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_8value(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
869 __Pyx_RefNannyFinishContext();
873 /* "bintrees\cwalker.pyx":36
876 * def value(self): # <<<<<<<<<<<<<<
877 * return <object> self.node.value
881 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_8value(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
882 PyObject *__pyx_r = NULL;
883 __Pyx_RefNannyDeclarations
884 __Pyx_RefNannySetupContext("value", 0);
886 /* "bintrees\cwalker.pyx":37
889 * return <object> self.node.value # <<<<<<<<<<<<<<
893 __Pyx_XDECREF(__pyx_r);
894 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->value));
895 __pyx_r = ((PyObject *)__pyx_v_self->node->value);
898 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
900 __Pyx_XGIVEREF(__pyx_r);
901 __Pyx_RefNannyFinishContext();
906 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_11item(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
907 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_11item(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
908 PyObject *__pyx_r = 0;
909 __Pyx_RefNannyDeclarations
910 __Pyx_RefNannySetupContext("item (wrapper)", 0);
911 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_10item(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
912 __Pyx_RefNannyFinishContext();
916 /* "bintrees\cwalker.pyx":40
919 * def item(self): # <<<<<<<<<<<<<<
920 * return (<object>self.node.key, <object>self.node.value)
924 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_10item(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
925 PyObject *__pyx_r = NULL;
926 __Pyx_RefNannyDeclarations
927 PyObject *__pyx_t_1 = NULL;
928 int __pyx_lineno = 0;
929 const char *__pyx_filename = NULL;
930 int __pyx_clineno = 0;
931 __Pyx_RefNannySetupContext("item", 0);
933 /* "bintrees\cwalker.pyx":41
936 * return (<object>self.node.key, <object>self.node.value) # <<<<<<<<<<<<<<
940 __Pyx_XDECREF(__pyx_r);
941 __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
942 __Pyx_GOTREF(__pyx_t_1);
943 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->key));
944 PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->node->key));
945 __Pyx_GIVEREF(((PyObject *)__pyx_v_self->node->key));
946 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->value));
947 PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self->node->value));
948 __Pyx_GIVEREF(((PyObject *)__pyx_v_self->node->value));
949 __pyx_r = ((PyObject *)__pyx_t_1);
953 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
956 __Pyx_XDECREF(__pyx_t_1);
957 __Pyx_AddTraceback("bintrees.cwalker.cWalker.item", __pyx_clineno, __pyx_lineno, __pyx_filename);
960 __Pyx_XGIVEREF(__pyx_r);
961 __Pyx_RefNannyFinishContext();
966 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_13is_valid(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
967 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_13is_valid(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
968 PyObject *__pyx_r = 0;
969 __Pyx_RefNannyDeclarations
970 __Pyx_RefNannySetupContext("is_valid (wrapper)", 0);
971 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_12is_valid(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
972 __Pyx_RefNannyFinishContext();
976 /* "bintrees\cwalker.pyx":44
979 * def is_valid(self): # <<<<<<<<<<<<<<
980 * return self.node != NULL
984 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_12is_valid(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
985 PyObject *__pyx_r = NULL;
986 __Pyx_RefNannyDeclarations
987 PyObject *__pyx_t_1 = NULL;
988 int __pyx_lineno = 0;
989 const char *__pyx_filename = NULL;
990 int __pyx_clineno = 0;
991 __Pyx_RefNannySetupContext("is_valid", 0);
993 /* "bintrees\cwalker.pyx":45
995 * def is_valid(self):
996 * return self.node != NULL # <<<<<<<<<<<<<<
998 * def goto(self, key):
1000 __Pyx_XDECREF(__pyx_r);
1001 __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->node != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1002 __Pyx_GOTREF(__pyx_t_1);
1003 __pyx_r = __pyx_t_1;
1007 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1010 __Pyx_XDECREF(__pyx_t_1);
1011 __Pyx_AddTraceback("bintrees.cwalker.cWalker.is_valid", __pyx_clineno, __pyx_lineno, __pyx_filename);
1014 __Pyx_XGIVEREF(__pyx_r);
1015 __Pyx_RefNannyFinishContext();
1019 /* Python wrapper */
1020 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_15goto(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
1021 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_15goto(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
1022 PyObject *__pyx_r = 0;
1023 __Pyx_RefNannyDeclarations
1024 __Pyx_RefNannySetupContext("goto (wrapper)", 0);
1025 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_14goto(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self), ((PyObject *)__pyx_v_key));
1026 __Pyx_RefNannyFinishContext();
1030 /* "bintrees\cwalker.pyx":47
1031 * return self.node != NULL
1033 * def goto(self, key): # <<<<<<<<<<<<<<
1035 * self.node = self.root
1038 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_14goto(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, PyObject *__pyx_v_key) {
1040 PyObject *__pyx_r = NULL;
1041 __Pyx_RefNannyDeclarations
1044 PyObject *__pyx_t_3 = NULL;
1045 int __pyx_lineno = 0;
1046 const char *__pyx_filename = NULL;
1047 int __pyx_clineno = 0;
1048 __Pyx_RefNannySetupContext("goto", 0);
1050 /* "bintrees\cwalker.pyx":49
1051 * def goto(self, key):
1053 * self.node = self.root # <<<<<<<<<<<<<<
1054 * while self.node != NULL:
1055 * cval = ct_compare(key, <object> self.node.key)
1057 __pyx_t_1 = __pyx_v_self->root;
1058 __pyx_v_self->node = __pyx_t_1;
1060 /* "bintrees\cwalker.pyx":50
1062 * self.node = self.root
1063 * while self.node != NULL: # <<<<<<<<<<<<<<
1064 * cval = ct_compare(key, <object> self.node.key)
1068 __pyx_t_2 = (__pyx_v_self->node != NULL);
1069 if (!__pyx_t_2) break;
1071 /* "bintrees\cwalker.pyx":51
1072 * self.node = self.root
1073 * while self.node != NULL:
1074 * cval = ct_compare(key, <object> self.node.key) # <<<<<<<<<<<<<<
1078 __pyx_t_3 = ((PyObject *)__pyx_v_self->node->key);
1079 __Pyx_INCREF(__pyx_t_3);
1080 __pyx_v_cval = ct_compare(__pyx_v_key, __pyx_t_3);
1081 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1083 /* "bintrees\cwalker.pyx":52
1084 * while self.node != NULL:
1085 * cval = ct_compare(key, <object> self.node.key)
1086 * if cval == 0: # <<<<<<<<<<<<<<
1090 __pyx_t_2 = (__pyx_v_cval == 0);
1093 /* "bintrees\cwalker.pyx":53
1094 * cval = ct_compare(key, <object> self.node.key)
1096 * return True # <<<<<<<<<<<<<<
1098 * self.node = self.node.link[0]
1100 __Pyx_XDECREF(__pyx_r);
1101 __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1102 __Pyx_GOTREF(__pyx_t_3);
1103 __pyx_r = __pyx_t_3;
1109 /* "bintrees\cwalker.pyx":54
1112 * elif cval < 0: # <<<<<<<<<<<<<<
1113 * self.node = self.node.link[0]
1116 __pyx_t_2 = (__pyx_v_cval < 0);
1119 /* "bintrees\cwalker.pyx":55
1122 * self.node = self.node.link[0] # <<<<<<<<<<<<<<
1124 * self.node = self.node.link[1]
1126 __pyx_v_self->node = (__pyx_v_self->node->link[0]);
1131 /* "bintrees\cwalker.pyx":57
1132 * self.node = self.node.link[0]
1134 * self.node = self.node.link[1] # <<<<<<<<<<<<<<
1138 __pyx_v_self->node = (__pyx_v_self->node->link[1]);
1143 /* "bintrees\cwalker.pyx":58
1145 * self.node = self.node.link[1]
1146 * return False # <<<<<<<<<<<<<<
1150 __Pyx_XDECREF(__pyx_r);
1151 __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1152 __Pyx_GOTREF(__pyx_t_3);
1153 __pyx_r = __pyx_t_3;
1157 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1160 __Pyx_XDECREF(__pyx_t_3);
1161 __Pyx_AddTraceback("bintrees.cwalker.cWalker.goto", __pyx_clineno, __pyx_lineno, __pyx_filename);
1164 __Pyx_XGIVEREF(__pyx_r);
1165 __Pyx_RefNannyFinishContext();
1169 /* "bintrees\cwalker.pyx":60
1172 * cpdef push(self): # <<<<<<<<<<<<<<
1173 * stack_push(self.stack, self.node)
1177 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_17push(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1178 static PyObject *__pyx_f_8bintrees_7cwalker_7cWalker_push(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, int __pyx_skip_dispatch) {
1179 PyObject *__pyx_r = NULL;
1180 __Pyx_RefNannyDeclarations
1181 PyObject *__pyx_t_1 = NULL;
1182 PyObject *__pyx_t_2 = NULL;
1183 int __pyx_lineno = 0;
1184 const char *__pyx_filename = NULL;
1185 int __pyx_clineno = 0;
1186 __Pyx_RefNannySetupContext("push", 0);
1187 /* Check if called by wrapper */
1188 if (unlikely(__pyx_skip_dispatch)) ;
1189 /* Check if overriden in Python */
1190 else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
1191 __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__push); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1192 __Pyx_GOTREF(__pyx_t_1);
1193 if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_17push)) {
1194 __Pyx_XDECREF(__pyx_r);
1195 __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1196 __Pyx_GOTREF(__pyx_t_2);
1197 __pyx_r = __pyx_t_2;
1199 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1202 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1205 /* "bintrees\cwalker.pyx":61
1208 * stack_push(self.stack, self.node) # <<<<<<<<<<<<<<
1212 stack_push(__pyx_v_self->stack, __pyx_v_self->node);
1214 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1217 __Pyx_XDECREF(__pyx_t_1);
1218 __Pyx_XDECREF(__pyx_t_2);
1219 __Pyx_AddTraceback("bintrees.cwalker.cWalker.push", __pyx_clineno, __pyx_lineno, __pyx_filename);
1222 __Pyx_XGIVEREF(__pyx_r);
1223 __Pyx_RefNannyFinishContext();
1227 /* Python wrapper */
1228 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_17push(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1229 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_17push(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1230 PyObject *__pyx_r = 0;
1231 __Pyx_RefNannyDeclarations
1232 __Pyx_RefNannySetupContext("push (wrapper)", 0);
1233 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_16push(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
1234 __Pyx_RefNannyFinishContext();
1238 /* "bintrees\cwalker.pyx":60
1241 * cpdef push(self): # <<<<<<<<<<<<<<
1242 * stack_push(self.stack, self.node)
1246 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_16push(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
1247 PyObject *__pyx_r = NULL;
1248 __Pyx_RefNannyDeclarations
1249 PyObject *__pyx_t_1 = NULL;
1250 int __pyx_lineno = 0;
1251 const char *__pyx_filename = NULL;
1252 int __pyx_clineno = 0;
1253 __Pyx_RefNannySetupContext("push", 0);
1254 __Pyx_XDECREF(__pyx_r);
1255 __pyx_t_1 = ((struct __pyx_vtabstruct_8bintrees_7cwalker_cWalker *)__pyx_v_self->__pyx_vtab)->push(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1256 __Pyx_GOTREF(__pyx_t_1);
1257 __pyx_r = __pyx_t_1;
1261 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1264 __Pyx_XDECREF(__pyx_t_1);
1265 __Pyx_AddTraceback("bintrees.cwalker.cWalker.push", __pyx_clineno, __pyx_lineno, __pyx_filename);
1268 __Pyx_XGIVEREF(__pyx_r);
1269 __Pyx_RefNannyFinishContext();
1273 /* "bintrees\cwalker.pyx":63
1274 * stack_push(self.stack, self.node)
1276 * cpdef pop(self): # <<<<<<<<<<<<<<
1277 * if stack_is_empty(self.stack) != 0:
1278 * raise IndexError('pop(): stack is empty')
1281 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_19pop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1282 static PyObject *__pyx_f_8bintrees_7cwalker_7cWalker_pop(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, int __pyx_skip_dispatch) {
1283 PyObject *__pyx_r = NULL;
1284 __Pyx_RefNannyDeclarations
1285 PyObject *__pyx_t_1 = NULL;
1286 PyObject *__pyx_t_2 = NULL;
1288 int __pyx_lineno = 0;
1289 const char *__pyx_filename = NULL;
1290 int __pyx_clineno = 0;
1291 __Pyx_RefNannySetupContext("pop", 0);
1292 /* Check if called by wrapper */
1293 if (unlikely(__pyx_skip_dispatch)) ;
1294 /* Check if overriden in Python */
1295 else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
1296 __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__pop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1297 __Pyx_GOTREF(__pyx_t_1);
1298 if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_19pop)) {
1299 __Pyx_XDECREF(__pyx_r);
1300 __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1301 __Pyx_GOTREF(__pyx_t_2);
1302 __pyx_r = __pyx_t_2;
1304 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1307 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1310 /* "bintrees\cwalker.pyx":64
1313 * if stack_is_empty(self.stack) != 0: # <<<<<<<<<<<<<<
1314 * raise IndexError('pop(): stack is empty')
1315 * self.node = stack_pop(self.stack)
1317 __pyx_t_3 = (stack_is_empty(__pyx_v_self->stack) != 0);
1320 /* "bintrees\cwalker.pyx":65
1322 * if stack_is_empty(self.stack) != 0:
1323 * raise IndexError('pop(): stack is empty') # <<<<<<<<<<<<<<
1324 * self.node = stack_pop(self.stack)
1327 __pyx_t_1 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1328 __Pyx_GOTREF(__pyx_t_1);
1329 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
1330 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1331 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1336 /* "bintrees\cwalker.pyx":66
1337 * if stack_is_empty(self.stack) != 0:
1338 * raise IndexError('pop(): stack is empty')
1339 * self.node = stack_pop(self.stack) # <<<<<<<<<<<<<<
1341 * def stack_is_empty(self):
1343 __pyx_v_self->node = stack_pop(__pyx_v_self->stack);
1345 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1348 __Pyx_XDECREF(__pyx_t_1);
1349 __Pyx_XDECREF(__pyx_t_2);
1350 __Pyx_AddTraceback("bintrees.cwalker.cWalker.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
1353 __Pyx_XGIVEREF(__pyx_r);
1354 __Pyx_RefNannyFinishContext();
1358 /* Python wrapper */
1359 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_19pop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1360 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_19pop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1361 PyObject *__pyx_r = 0;
1362 __Pyx_RefNannyDeclarations
1363 __Pyx_RefNannySetupContext("pop (wrapper)", 0);
1364 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_18pop(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
1365 __Pyx_RefNannyFinishContext();
1369 /* "bintrees\cwalker.pyx":63
1370 * stack_push(self.stack, self.node)
1372 * cpdef pop(self): # <<<<<<<<<<<<<<
1373 * if stack_is_empty(self.stack) != 0:
1374 * raise IndexError('pop(): stack is empty')
1377 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_18pop(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
1378 PyObject *__pyx_r = NULL;
1379 __Pyx_RefNannyDeclarations
1380 PyObject *__pyx_t_1 = NULL;
1381 int __pyx_lineno = 0;
1382 const char *__pyx_filename = NULL;
1383 int __pyx_clineno = 0;
1384 __Pyx_RefNannySetupContext("pop", 0);
1385 __Pyx_XDECREF(__pyx_r);
1386 __pyx_t_1 = ((struct __pyx_vtabstruct_8bintrees_7cwalker_cWalker *)__pyx_v_self->__pyx_vtab)->pop(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1387 __Pyx_GOTREF(__pyx_t_1);
1388 __pyx_r = __pyx_t_1;
1392 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1395 __Pyx_XDECREF(__pyx_t_1);
1396 __Pyx_AddTraceback("bintrees.cwalker.cWalker.pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
1399 __Pyx_XGIVEREF(__pyx_r);
1400 __Pyx_RefNannyFinishContext();
1404 /* Python wrapper */
1405 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_21stack_is_empty(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1406 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_21stack_is_empty(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1407 PyObject *__pyx_r = 0;
1408 __Pyx_RefNannyDeclarations
1409 __Pyx_RefNannySetupContext("stack_is_empty (wrapper)", 0);
1410 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_20stack_is_empty(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
1411 __Pyx_RefNannyFinishContext();
1415 /* "bintrees\cwalker.pyx":68
1416 * self.node = stack_pop(self.stack)
1418 * def stack_is_empty(self): # <<<<<<<<<<<<<<
1419 * return <bint> stack_is_empty(self.stack)
1423 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_20stack_is_empty(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
1424 PyObject *__pyx_r = NULL;
1425 __Pyx_RefNannyDeclarations
1426 PyObject *__pyx_t_1 = NULL;
1427 int __pyx_lineno = 0;
1428 const char *__pyx_filename = NULL;
1429 int __pyx_clineno = 0;
1430 __Pyx_RefNannySetupContext("stack_is_empty", 0);
1432 /* "bintrees\cwalker.pyx":69
1434 * def stack_is_empty(self):
1435 * return <bint> stack_is_empty(self.stack) # <<<<<<<<<<<<<<
1437 * def goto_leaf(self):
1439 __Pyx_XDECREF(__pyx_r);
1440 __pyx_t_1 = __Pyx_PyBool_FromLong(((int)stack_is_empty(__pyx_v_self->stack))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1441 __Pyx_GOTREF(__pyx_t_1);
1442 __pyx_r = __pyx_t_1;
1446 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1449 __Pyx_XDECREF(__pyx_t_1);
1450 __Pyx_AddTraceback("bintrees.cwalker.cWalker.stack_is_empty", __pyx_clineno, __pyx_lineno, __pyx_filename);
1453 __Pyx_XGIVEREF(__pyx_r);
1454 __Pyx_RefNannyFinishContext();
1458 /* Python wrapper */
1459 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_23goto_leaf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1460 static char __pyx_doc_8bintrees_7cwalker_7cWalker_22goto_leaf[] = " get a leaf node ";
1461 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_23goto_leaf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1462 PyObject *__pyx_r = 0;
1463 __Pyx_RefNannyDeclarations
1464 __Pyx_RefNannySetupContext("goto_leaf (wrapper)", 0);
1465 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_22goto_leaf(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
1466 __Pyx_RefNannyFinishContext();
1470 /* "bintrees\cwalker.pyx":71
1471 * return <bint> stack_is_empty(self.stack)
1473 * def goto_leaf(self): # <<<<<<<<<<<<<<
1474 * """ get a leaf node """
1475 * while self.node != NULL:
1478 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_22goto_leaf(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
1479 PyObject *__pyx_r = NULL;
1480 __Pyx_RefNannyDeclarations
1482 __Pyx_RefNannySetupContext("goto_leaf", 0);
1484 /* "bintrees\cwalker.pyx":73
1485 * def goto_leaf(self):
1486 * """ get a leaf node """
1487 * while self.node != NULL: # <<<<<<<<<<<<<<
1488 * if self.node.link[0] != NULL:
1489 * self.node = self.node.link[0]
1492 __pyx_t_1 = (__pyx_v_self->node != NULL);
1493 if (!__pyx_t_1) break;
1495 /* "bintrees\cwalker.pyx":74
1496 * """ get a leaf node """
1497 * while self.node != NULL:
1498 * if self.node.link[0] != NULL: # <<<<<<<<<<<<<<
1499 * self.node = self.node.link[0]
1500 * elif self.node.link[1] != NULL:
1502 __pyx_t_1 = ((__pyx_v_self->node->link[0]) != NULL);
1505 /* "bintrees\cwalker.pyx":75
1506 * while self.node != NULL:
1507 * if self.node.link[0] != NULL:
1508 * self.node = self.node.link[0] # <<<<<<<<<<<<<<
1509 * elif self.node.link[1] != NULL:
1510 * self.node = self.node.link[1]
1512 __pyx_v_self->node = (__pyx_v_self->node->link[0]);
1516 /* "bintrees\cwalker.pyx":76
1517 * if self.node.link[0] != NULL:
1518 * self.node = self.node.link[0]
1519 * elif self.node.link[1] != NULL: # <<<<<<<<<<<<<<
1520 * self.node = self.node.link[1]
1523 __pyx_t_1 = ((__pyx_v_self->node->link[1]) != NULL);
1526 /* "bintrees\cwalker.pyx":77
1527 * self.node = self.node.link[0]
1528 * elif self.node.link[1] != NULL:
1529 * self.node = self.node.link[1] # <<<<<<<<<<<<<<
1533 __pyx_v_self->node = (__pyx_v_self->node->link[1]);
1538 /* "bintrees\cwalker.pyx":79
1539 * self.node = self.node.link[1]
1541 * return # <<<<<<<<<<<<<<
1543 * def has_child(self, int direction):
1545 __Pyx_XDECREF(__pyx_r);
1546 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1552 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1554 __Pyx_XGIVEREF(__pyx_r);
1555 __Pyx_RefNannyFinishContext();
1559 /* Python wrapper */
1560 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_25has_child(PyObject *__pyx_v_self, PyObject *__pyx_arg_direction); /*proto*/
1561 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_25has_child(PyObject *__pyx_v_self, PyObject *__pyx_arg_direction) {
1562 int __pyx_v_direction;
1563 PyObject *__pyx_r = 0;
1564 __Pyx_RefNannyDeclarations
1565 __Pyx_RefNannySetupContext("has_child (wrapper)", 0);
1566 assert(__pyx_arg_direction); {
1567 __pyx_v_direction = __Pyx_PyInt_AsInt(__pyx_arg_direction); if (unlikely((__pyx_v_direction == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1569 goto __pyx_L4_argument_unpacking_done;
1571 __Pyx_AddTraceback("bintrees.cwalker.cWalker.has_child", __pyx_clineno, __pyx_lineno, __pyx_filename);
1572 __Pyx_RefNannyFinishContext();
1574 __pyx_L4_argument_unpacking_done:;
1575 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_24has_child(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self), ((int)__pyx_v_direction));
1576 __Pyx_RefNannyFinishContext();
1580 /* "bintrees\cwalker.pyx":81
1583 * def has_child(self, int direction): # <<<<<<<<<<<<<<
1584 * return self.node.link[direction] != NULL
1588 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_24has_child(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, int __pyx_v_direction) {
1589 PyObject *__pyx_r = NULL;
1590 __Pyx_RefNannyDeclarations
1591 PyObject *__pyx_t_1 = NULL;
1592 int __pyx_lineno = 0;
1593 const char *__pyx_filename = NULL;
1594 int __pyx_clineno = 0;
1595 __Pyx_RefNannySetupContext("has_child", 0);
1597 /* "bintrees\cwalker.pyx":82
1599 * def has_child(self, int direction):
1600 * return self.node.link[direction] != NULL # <<<<<<<<<<<<<<
1602 * def down(self, int direction):
1604 __Pyx_XDECREF(__pyx_r);
1605 __pyx_t_1 = __Pyx_PyBool_FromLong(((__pyx_v_self->node->link[__pyx_v_direction]) != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1606 __Pyx_GOTREF(__pyx_t_1);
1607 __pyx_r = __pyx_t_1;
1611 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1614 __Pyx_XDECREF(__pyx_t_1);
1615 __Pyx_AddTraceback("bintrees.cwalker.cWalker.has_child", __pyx_clineno, __pyx_lineno, __pyx_filename);
1618 __Pyx_XGIVEREF(__pyx_r);
1619 __Pyx_RefNannyFinishContext();
1623 /* Python wrapper */
1624 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_27down(PyObject *__pyx_v_self, PyObject *__pyx_arg_direction); /*proto*/
1625 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_27down(PyObject *__pyx_v_self, PyObject *__pyx_arg_direction) {
1626 int __pyx_v_direction;
1627 PyObject *__pyx_r = 0;
1628 __Pyx_RefNannyDeclarations
1629 __Pyx_RefNannySetupContext("down (wrapper)", 0);
1630 assert(__pyx_arg_direction); {
1631 __pyx_v_direction = __Pyx_PyInt_AsInt(__pyx_arg_direction); if (unlikely((__pyx_v_direction == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1633 goto __pyx_L4_argument_unpacking_done;
1635 __Pyx_AddTraceback("bintrees.cwalker.cWalker.down", __pyx_clineno, __pyx_lineno, __pyx_filename);
1636 __Pyx_RefNannyFinishContext();
1638 __pyx_L4_argument_unpacking_done:;
1639 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_26down(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self), ((int)__pyx_v_direction));
1640 __Pyx_RefNannyFinishContext();
1644 /* "bintrees\cwalker.pyx":84
1645 * return self.node.link[direction] != NULL
1647 * def down(self, int direction): # <<<<<<<<<<<<<<
1648 * self.node = self.node.link[direction]
1652 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_26down(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, int __pyx_v_direction) {
1653 PyObject *__pyx_r = NULL;
1654 __Pyx_RefNannyDeclarations
1655 __Pyx_RefNannySetupContext("down", 0);
1657 /* "bintrees\cwalker.pyx":85
1659 * def down(self, int direction):
1660 * self.node = self.node.link[direction] # <<<<<<<<<<<<<<
1662 * def go_left(self):
1664 __pyx_v_self->node = (__pyx_v_self->node->link[__pyx_v_direction]);
1666 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1667 __Pyx_XGIVEREF(__pyx_r);
1668 __Pyx_RefNannyFinishContext();
1672 /* Python wrapper */
1673 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_29go_left(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1674 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_29go_left(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1675 PyObject *__pyx_r = 0;
1676 __Pyx_RefNannyDeclarations
1677 __Pyx_RefNannySetupContext("go_left (wrapper)", 0);
1678 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_28go_left(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
1679 __Pyx_RefNannyFinishContext();
1683 /* "bintrees\cwalker.pyx":87
1684 * self.node = self.node.link[direction]
1686 * def go_left(self): # <<<<<<<<<<<<<<
1687 * self.node = self.node.link[0]
1691 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_28go_left(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
1692 PyObject *__pyx_r = NULL;
1693 __Pyx_RefNannyDeclarations
1694 __Pyx_RefNannySetupContext("go_left", 0);
1696 /* "bintrees\cwalker.pyx":88
1698 * def go_left(self):
1699 * self.node = self.node.link[0] # <<<<<<<<<<<<<<
1701 * def go_right(self):
1703 __pyx_v_self->node = (__pyx_v_self->node->link[0]);
1705 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1706 __Pyx_XGIVEREF(__pyx_r);
1707 __Pyx_RefNannyFinishContext();
1711 /* Python wrapper */
1712 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_31go_right(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1713 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_31go_right(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1714 PyObject *__pyx_r = 0;
1715 __Pyx_RefNannyDeclarations
1716 __Pyx_RefNannySetupContext("go_right (wrapper)", 0);
1717 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_30go_right(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
1718 __Pyx_RefNannyFinishContext();
1722 /* "bintrees\cwalker.pyx":90
1723 * self.node = self.node.link[0]
1725 * def go_right(self): # <<<<<<<<<<<<<<
1726 * self.node = self.node.link[1]
1730 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_30go_right(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
1731 PyObject *__pyx_r = NULL;
1732 __Pyx_RefNannyDeclarations
1733 __Pyx_RefNannySetupContext("go_right", 0);
1735 /* "bintrees\cwalker.pyx":91
1737 * def go_right(self):
1738 * self.node = self.node.link[1] # <<<<<<<<<<<<<<
1740 * def has_left(self):
1742 __pyx_v_self->node = (__pyx_v_self->node->link[1]);
1744 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1745 __Pyx_XGIVEREF(__pyx_r);
1746 __Pyx_RefNannyFinishContext();
1750 /* Python wrapper */
1751 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_33has_left(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1752 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_33has_left(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1753 PyObject *__pyx_r = 0;
1754 __Pyx_RefNannyDeclarations
1755 __Pyx_RefNannySetupContext("has_left (wrapper)", 0);
1756 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_32has_left(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
1757 __Pyx_RefNannyFinishContext();
1761 /* "bintrees\cwalker.pyx":93
1762 * self.node = self.node.link[1]
1764 * def has_left(self): # <<<<<<<<<<<<<<
1765 * return self.node.link[0] != NULL
1769 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_32has_left(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
1770 PyObject *__pyx_r = NULL;
1771 __Pyx_RefNannyDeclarations
1772 PyObject *__pyx_t_1 = NULL;
1773 int __pyx_lineno = 0;
1774 const char *__pyx_filename = NULL;
1775 int __pyx_clineno = 0;
1776 __Pyx_RefNannySetupContext("has_left", 0);
1778 /* "bintrees\cwalker.pyx":94
1780 * def has_left(self):
1781 * return self.node.link[0] != NULL # <<<<<<<<<<<<<<
1783 * def has_right(self):
1785 __Pyx_XDECREF(__pyx_r);
1786 __pyx_t_1 = __Pyx_PyBool_FromLong(((__pyx_v_self->node->link[0]) != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1787 __Pyx_GOTREF(__pyx_t_1);
1788 __pyx_r = __pyx_t_1;
1792 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1795 __Pyx_XDECREF(__pyx_t_1);
1796 __Pyx_AddTraceback("bintrees.cwalker.cWalker.has_left", __pyx_clineno, __pyx_lineno, __pyx_filename);
1799 __Pyx_XGIVEREF(__pyx_r);
1800 __Pyx_RefNannyFinishContext();
1804 /* Python wrapper */
1805 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_35has_right(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1806 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_35has_right(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1807 PyObject *__pyx_r = 0;
1808 __Pyx_RefNannyDeclarations
1809 __Pyx_RefNannySetupContext("has_right (wrapper)", 0);
1810 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_34has_right(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self));
1811 __Pyx_RefNannyFinishContext();
1815 /* "bintrees\cwalker.pyx":96
1816 * return self.node.link[0] != NULL
1818 * def has_right(self): # <<<<<<<<<<<<<<
1819 * return self.node.link[1] != NULL
1823 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_34has_right(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self) {
1824 PyObject *__pyx_r = NULL;
1825 __Pyx_RefNannyDeclarations
1826 PyObject *__pyx_t_1 = NULL;
1827 int __pyx_lineno = 0;
1828 const char *__pyx_filename = NULL;
1829 int __pyx_clineno = 0;
1830 __Pyx_RefNannySetupContext("has_right", 0);
1832 /* "bintrees\cwalker.pyx":97
1834 * def has_right(self):
1835 * return self.node.link[1] != NULL # <<<<<<<<<<<<<<
1837 * def succ_item(self, key):
1839 __Pyx_XDECREF(__pyx_r);
1840 __pyx_t_1 = __Pyx_PyBool_FromLong(((__pyx_v_self->node->link[1]) != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1841 __Pyx_GOTREF(__pyx_t_1);
1842 __pyx_r = __pyx_t_1;
1846 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1849 __Pyx_XDECREF(__pyx_t_1);
1850 __Pyx_AddTraceback("bintrees.cwalker.cWalker.has_right", __pyx_clineno, __pyx_lineno, __pyx_filename);
1853 __Pyx_XGIVEREF(__pyx_r);
1854 __Pyx_RefNannyFinishContext();
1858 /* Python wrapper */
1859 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_37succ_item(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
1860 static char __pyx_doc_8bintrees_7cwalker_7cWalker_36succ_item[] = " Get successor (k,v) pair of key, raises KeyError if key is max key\n or key does not exist.\n ";
1861 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_37succ_item(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
1862 PyObject *__pyx_r = 0;
1863 __Pyx_RefNannyDeclarations
1864 __Pyx_RefNannySetupContext("succ_item (wrapper)", 0);
1865 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_36succ_item(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self), ((PyObject *)__pyx_v_key));
1866 __Pyx_RefNannyFinishContext();
1870 /* "bintrees\cwalker.pyx":99
1871 * return self.node.link[1] != NULL
1873 * def succ_item(self, key): # <<<<<<<<<<<<<<
1874 * """ Get successor (k,v) pair of key, raises KeyError if key is max key
1875 * or key does not exist.
1878 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_36succ_item(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, PyObject *__pyx_v_key) {
1879 PyObject *__pyx_r = NULL;
1880 __Pyx_RefNannyDeclarations
1882 PyObject *__pyx_t_2 = NULL;
1883 PyObject *__pyx_t_3 = NULL;
1884 int __pyx_lineno = 0;
1885 const char *__pyx_filename = NULL;
1886 int __pyx_clineno = 0;
1887 __Pyx_RefNannySetupContext("succ_item", 0);
1889 /* "bintrees\cwalker.pyx":103
1890 * or key does not exist.
1892 * self.node = ct_succ_node(self.root, key) # <<<<<<<<<<<<<<
1893 * if self.node == NULL: # given key is biggest in tree
1894 * raise KeyError(str(key))
1896 __pyx_v_self->node = ct_succ_node(__pyx_v_self->root, __pyx_v_key);
1898 /* "bintrees\cwalker.pyx":104
1900 * self.node = ct_succ_node(self.root, key)
1901 * if self.node == NULL: # given key is biggest in tree # <<<<<<<<<<<<<<
1902 * raise KeyError(str(key))
1903 * return (<object> self.node.key, <object> self.node.value)
1905 __pyx_t_1 = (__pyx_v_self->node == NULL);
1908 /* "bintrees\cwalker.pyx":105
1909 * self.node = ct_succ_node(self.root, key)
1910 * if self.node == NULL: # given key is biggest in tree
1911 * raise KeyError(str(key)) # <<<<<<<<<<<<<<
1912 * return (<object> self.node.key, <object> self.node.value)
1915 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1916 __Pyx_GOTREF(__pyx_t_2);
1917 __Pyx_INCREF(__pyx_v_key);
1918 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
1919 __Pyx_GIVEREF(__pyx_v_key);
1920 __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1921 __Pyx_GOTREF(__pyx_t_3);
1922 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
1923 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1924 __Pyx_GOTREF(__pyx_t_2);
1925 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
1926 __Pyx_GIVEREF(__pyx_t_3);
1928 __pyx_t_3 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1929 __Pyx_GOTREF(__pyx_t_3);
1930 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
1931 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
1932 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1933 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1938 /* "bintrees\cwalker.pyx":106
1939 * if self.node == NULL: # given key is biggest in tree
1940 * raise KeyError(str(key))
1941 * return (<object> self.node.key, <object> self.node.value) # <<<<<<<<<<<<<<
1943 * def prev_item(self, key):
1945 __Pyx_XDECREF(__pyx_r);
1946 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1947 __Pyx_GOTREF(__pyx_t_3);
1948 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->key));
1949 PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->node->key));
1950 __Pyx_GIVEREF(((PyObject *)__pyx_v_self->node->key));
1951 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->value));
1952 PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self->node->value));
1953 __Pyx_GIVEREF(((PyObject *)__pyx_v_self->node->value));
1954 __pyx_r = ((PyObject *)__pyx_t_3);
1958 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1961 __Pyx_XDECREF(__pyx_t_2);
1962 __Pyx_XDECREF(__pyx_t_3);
1963 __Pyx_AddTraceback("bintrees.cwalker.cWalker.succ_item", __pyx_clineno, __pyx_lineno, __pyx_filename);
1966 __Pyx_XGIVEREF(__pyx_r);
1967 __Pyx_RefNannyFinishContext();
1971 /* Python wrapper */
1972 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_39prev_item(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
1973 static char __pyx_doc_8bintrees_7cwalker_7cWalker_38prev_item[] = " Get predecessor (k,v) pair of key, raises KeyError if key is min key\n or key does not exist.\n ";
1974 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_39prev_item(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
1975 PyObject *__pyx_r = 0;
1976 __Pyx_RefNannyDeclarations
1977 __Pyx_RefNannySetupContext("prev_item (wrapper)", 0);
1978 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_38prev_item(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self), ((PyObject *)__pyx_v_key));
1979 __Pyx_RefNannyFinishContext();
1983 /* "bintrees\cwalker.pyx":108
1984 * return (<object> self.node.key, <object> self.node.value)
1986 * def prev_item(self, key): # <<<<<<<<<<<<<<
1987 * """ Get predecessor (k,v) pair of key, raises KeyError if key is min key
1988 * or key does not exist.
1991 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_38prev_item(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, PyObject *__pyx_v_key) {
1992 PyObject *__pyx_r = NULL;
1993 __Pyx_RefNannyDeclarations
1995 PyObject *__pyx_t_2 = NULL;
1996 PyObject *__pyx_t_3 = NULL;
1997 int __pyx_lineno = 0;
1998 const char *__pyx_filename = NULL;
1999 int __pyx_clineno = 0;
2000 __Pyx_RefNannySetupContext("prev_item", 0);
2002 /* "bintrees\cwalker.pyx":112
2003 * or key does not exist.
2005 * self.node = ct_prev_node(self.root, key) # <<<<<<<<<<<<<<
2006 * if self.node == NULL: # given key is smallest in tree
2007 * raise KeyError(str(key))
2009 __pyx_v_self->node = ct_prev_node(__pyx_v_self->root, __pyx_v_key);
2011 /* "bintrees\cwalker.pyx":113
2013 * self.node = ct_prev_node(self.root, key)
2014 * if self.node == NULL: # given key is smallest in tree # <<<<<<<<<<<<<<
2015 * raise KeyError(str(key))
2016 * return (<object> self.node.key, <object> self.node.value)
2018 __pyx_t_1 = (__pyx_v_self->node == NULL);
2021 /* "bintrees\cwalker.pyx":114
2022 * self.node = ct_prev_node(self.root, key)
2023 * if self.node == NULL: # given key is smallest in tree
2024 * raise KeyError(str(key)) # <<<<<<<<<<<<<<
2025 * return (<object> self.node.key, <object> self.node.value)
2028 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2029 __Pyx_GOTREF(__pyx_t_2);
2030 __Pyx_INCREF(__pyx_v_key);
2031 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
2032 __Pyx_GIVEREF(__pyx_v_key);
2033 __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2034 __Pyx_GOTREF(__pyx_t_3);
2035 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2036 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2037 __Pyx_GOTREF(__pyx_t_2);
2038 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
2039 __Pyx_GIVEREF(__pyx_t_3);
2041 __pyx_t_3 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2042 __Pyx_GOTREF(__pyx_t_3);
2043 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2044 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
2045 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2046 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2051 /* "bintrees\cwalker.pyx":115
2052 * if self.node == NULL: # given key is smallest in tree
2053 * raise KeyError(str(key))
2054 * return (<object> self.node.key, <object> self.node.value) # <<<<<<<<<<<<<<
2056 * def floor_item(self, key):
2058 __Pyx_XDECREF(__pyx_r);
2059 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2060 __Pyx_GOTREF(__pyx_t_3);
2061 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->key));
2062 PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->node->key));
2063 __Pyx_GIVEREF(((PyObject *)__pyx_v_self->node->key));
2064 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->value));
2065 PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self->node->value));
2066 __Pyx_GIVEREF(((PyObject *)__pyx_v_self->node->value));
2067 __pyx_r = ((PyObject *)__pyx_t_3);
2071 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2074 __Pyx_XDECREF(__pyx_t_2);
2075 __Pyx_XDECREF(__pyx_t_3);
2076 __Pyx_AddTraceback("bintrees.cwalker.cWalker.prev_item", __pyx_clineno, __pyx_lineno, __pyx_filename);
2079 __Pyx_XGIVEREF(__pyx_r);
2080 __Pyx_RefNannyFinishContext();
2084 /* Python wrapper */
2085 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_41floor_item(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
2086 static char __pyx_doc_8bintrees_7cwalker_7cWalker_40floor_item[] = " Get the element (k,v) pair associated with the greatest key less\n than or equal to the given key, raises KeyError if there is no such key.\n ";
2087 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_41floor_item(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
2088 PyObject *__pyx_r = 0;
2089 __Pyx_RefNannyDeclarations
2090 __Pyx_RefNannySetupContext("floor_item (wrapper)", 0);
2091 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_40floor_item(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self), ((PyObject *)__pyx_v_key));
2092 __Pyx_RefNannyFinishContext();
2096 /* "bintrees\cwalker.pyx":117
2097 * return (<object> self.node.key, <object> self.node.value)
2099 * def floor_item(self, key): # <<<<<<<<<<<<<<
2100 * """ Get the element (k,v) pair associated with the greatest key less
2101 * than or equal to the given key, raises KeyError if there is no such key.
2104 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_40floor_item(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, PyObject *__pyx_v_key) {
2105 PyObject *__pyx_r = NULL;
2106 __Pyx_RefNannyDeclarations
2108 PyObject *__pyx_t_2 = NULL;
2109 PyObject *__pyx_t_3 = NULL;
2110 int __pyx_lineno = 0;
2111 const char *__pyx_filename = NULL;
2112 int __pyx_clineno = 0;
2113 __Pyx_RefNannySetupContext("floor_item", 0);
2115 /* "bintrees\cwalker.pyx":121
2116 * than or equal to the given key, raises KeyError if there is no such key.
2118 * self.node = ct_floor_node(self.root, key) # <<<<<<<<<<<<<<
2119 * if self.node == NULL: # given key is smaller than min-key in tree
2120 * raise KeyError(str(key))
2122 __pyx_v_self->node = ct_floor_node(__pyx_v_self->root, __pyx_v_key);
2124 /* "bintrees\cwalker.pyx":122
2126 * self.node = ct_floor_node(self.root, key)
2127 * if self.node == NULL: # given key is smaller than min-key in tree # <<<<<<<<<<<<<<
2128 * raise KeyError(str(key))
2129 * return (<object> self.node.key, <object> self.node.value)
2131 __pyx_t_1 = (__pyx_v_self->node == NULL);
2134 /* "bintrees\cwalker.pyx":123
2135 * self.node = ct_floor_node(self.root, key)
2136 * if self.node == NULL: # given key is smaller than min-key in tree
2137 * raise KeyError(str(key)) # <<<<<<<<<<<<<<
2138 * return (<object> self.node.key, <object> self.node.value)
2141 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2142 __Pyx_GOTREF(__pyx_t_2);
2143 __Pyx_INCREF(__pyx_v_key);
2144 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
2145 __Pyx_GIVEREF(__pyx_v_key);
2146 __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2147 __Pyx_GOTREF(__pyx_t_3);
2148 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2149 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2150 __Pyx_GOTREF(__pyx_t_2);
2151 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
2152 __Pyx_GIVEREF(__pyx_t_3);
2154 __pyx_t_3 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2155 __Pyx_GOTREF(__pyx_t_3);
2156 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2157 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
2158 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2159 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2164 /* "bintrees\cwalker.pyx":124
2165 * if self.node == NULL: # given key is smaller than min-key in tree
2166 * raise KeyError(str(key))
2167 * return (<object> self.node.key, <object> self.node.value) # <<<<<<<<<<<<<<
2169 * def ceiling_item(self, key):
2171 __Pyx_XDECREF(__pyx_r);
2172 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2173 __Pyx_GOTREF(__pyx_t_3);
2174 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->key));
2175 PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->node->key));
2176 __Pyx_GIVEREF(((PyObject *)__pyx_v_self->node->key));
2177 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->value));
2178 PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self->node->value));
2179 __Pyx_GIVEREF(((PyObject *)__pyx_v_self->node->value));
2180 __pyx_r = ((PyObject *)__pyx_t_3);
2184 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2187 __Pyx_XDECREF(__pyx_t_2);
2188 __Pyx_XDECREF(__pyx_t_3);
2189 __Pyx_AddTraceback("bintrees.cwalker.cWalker.floor_item", __pyx_clineno, __pyx_lineno, __pyx_filename);
2192 __Pyx_XGIVEREF(__pyx_r);
2193 __Pyx_RefNannyFinishContext();
2197 /* Python wrapper */
2198 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_43ceiling_item(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
2199 static char __pyx_doc_8bintrees_7cwalker_7cWalker_42ceiling_item[] = " Get the element (k,v) pair associated with the smallest key greater\n than or equal to the given key, raises KeyError if there is no such key.\n ";
2200 static PyObject *__pyx_pw_8bintrees_7cwalker_7cWalker_43ceiling_item(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
2201 PyObject *__pyx_r = 0;
2202 __Pyx_RefNannyDeclarations
2203 __Pyx_RefNannySetupContext("ceiling_item (wrapper)", 0);
2204 __pyx_r = __pyx_pf_8bintrees_7cwalker_7cWalker_42ceiling_item(((struct __pyx_obj_8bintrees_7cwalker_cWalker *)__pyx_v_self), ((PyObject *)__pyx_v_key));
2205 __Pyx_RefNannyFinishContext();
2209 /* "bintrees\cwalker.pyx":126
2210 * return (<object> self.node.key, <object> self.node.value)
2212 * def ceiling_item(self, key): # <<<<<<<<<<<<<<
2213 * """ Get the element (k,v) pair associated with the smallest key greater
2214 * than or equal to the given key, raises KeyError if there is no such key.
2217 static PyObject *__pyx_pf_8bintrees_7cwalker_7cWalker_42ceiling_item(struct __pyx_obj_8bintrees_7cwalker_cWalker *__pyx_v_self, PyObject *__pyx_v_key) {
2218 PyObject *__pyx_r = NULL;
2219 __Pyx_RefNannyDeclarations
2221 PyObject *__pyx_t_2 = NULL;
2222 PyObject *__pyx_t_3 = NULL;
2223 int __pyx_lineno = 0;
2224 const char *__pyx_filename = NULL;
2225 int __pyx_clineno = 0;
2226 __Pyx_RefNannySetupContext("ceiling_item", 0);
2228 /* "bintrees\cwalker.pyx":130
2229 * than or equal to the given key, raises KeyError if there is no such key.
2231 * self.node = ct_ceiling_node(self.root, key) # <<<<<<<<<<<<<<
2232 * if self.node == NULL: # given key is greater than max-key in tree
2233 * raise KeyError(str(key))
2235 __pyx_v_self->node = ct_ceiling_node(__pyx_v_self->root, __pyx_v_key);
2237 /* "bintrees\cwalker.pyx":131
2239 * self.node = ct_ceiling_node(self.root, key)
2240 * if self.node == NULL: # given key is greater than max-key in tree # <<<<<<<<<<<<<<
2241 * raise KeyError(str(key))
2242 * return (<object> self.node.key, <object> self.node.value)
2244 __pyx_t_1 = (__pyx_v_self->node == NULL);
2247 /* "bintrees\cwalker.pyx":132
2248 * self.node = ct_ceiling_node(self.root, key)
2249 * if self.node == NULL: # given key is greater than max-key in tree
2250 * raise KeyError(str(key)) # <<<<<<<<<<<<<<
2251 * return (<object> self.node.key, <object> self.node.value)
2253 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2254 __Pyx_GOTREF(__pyx_t_2);
2255 __Pyx_INCREF(__pyx_v_key);
2256 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
2257 __Pyx_GIVEREF(__pyx_v_key);
2258 __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2259 __Pyx_GOTREF(__pyx_t_3);
2260 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2261 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2262 __Pyx_GOTREF(__pyx_t_2);
2263 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
2264 __Pyx_GIVEREF(__pyx_t_3);
2266 __pyx_t_3 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2267 __Pyx_GOTREF(__pyx_t_3);
2268 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2269 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
2270 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2271 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2276 /* "bintrees\cwalker.pyx":133
2277 * if self.node == NULL: # given key is greater than max-key in tree
2278 * raise KeyError(str(key))
2279 * return (<object> self.node.key, <object> self.node.value) # <<<<<<<<<<<<<<
2281 __Pyx_XDECREF(__pyx_r);
2282 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2283 __Pyx_GOTREF(__pyx_t_3);
2284 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->key));
2285 PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->node->key));
2286 __Pyx_GIVEREF(((PyObject *)__pyx_v_self->node->key));
2287 __Pyx_INCREF(((PyObject *)__pyx_v_self->node->value));
2288 PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self->node->value));
2289 __Pyx_GIVEREF(((PyObject *)__pyx_v_self->node->value));
2290 __pyx_r = ((PyObject *)__pyx_t_3);
2294 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2297 __Pyx_XDECREF(__pyx_t_2);
2298 __Pyx_XDECREF(__pyx_t_3);
2299 __Pyx_AddTraceback("bintrees.cwalker.cWalker.ceiling_item", __pyx_clineno, __pyx_lineno, __pyx_filename);
2302 __Pyx_XGIVEREF(__pyx_r);
2303 __Pyx_RefNannyFinishContext();
2306 static struct __pyx_vtabstruct_8bintrees_7cwalker_cWalker __pyx_vtable_8bintrees_7cwalker_cWalker;
2308 static PyObject *__pyx_tp_new_8bintrees_7cwalker_cWalker(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
2309 struct __pyx_obj_8bintrees_7cwalker_cWalker *p;
2310 PyObject *o = (*t->tp_alloc)(t, 0);
2312 p = ((struct __pyx_obj_8bintrees_7cwalker_cWalker *)o);
2313 p->__pyx_vtab = __pyx_vtabptr_8bintrees_7cwalker_cWalker;
2314 if (__pyx_pw_8bintrees_7cwalker_7cWalker_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) {
2315 Py_DECREF(o); o = 0;
2320 static void __pyx_tp_dealloc_8bintrees_7cwalker_cWalker(PyObject *o) {
2322 PyObject *etype, *eval, *etb;
2323 PyErr_Fetch(&etype, &eval, &etb);
2325 __pyx_pw_8bintrees_7cwalker_7cWalker_3__dealloc__(o);
2326 if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
2328 PyErr_Restore(etype, eval, etb);
2330 (*Py_TYPE(o)->tp_free)(o);
2333 static PyMethodDef __pyx_methods_8bintrees_7cwalker_cWalker[] = {
2334 {__Pyx_NAMESTR("reset"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_5reset, METH_NOARGS, __Pyx_DOCSTR(0)},
2335 {__Pyx_NAMESTR("key"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_7key, METH_NOARGS, __Pyx_DOCSTR(0)},
2336 {__Pyx_NAMESTR("value"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_9value, METH_NOARGS, __Pyx_DOCSTR(0)},
2337 {__Pyx_NAMESTR("item"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_11item, METH_NOARGS, __Pyx_DOCSTR(0)},
2338 {__Pyx_NAMESTR("is_valid"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_13is_valid, METH_NOARGS, __Pyx_DOCSTR(0)},
2339 {__Pyx_NAMESTR("goto"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_15goto, METH_O, __Pyx_DOCSTR(0)},
2340 {__Pyx_NAMESTR("push"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_17push, METH_NOARGS, __Pyx_DOCSTR(0)},
2341 {__Pyx_NAMESTR("pop"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_19pop, METH_NOARGS, __Pyx_DOCSTR(0)},
2342 {__Pyx_NAMESTR("stack_is_empty"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_21stack_is_empty, METH_NOARGS, __Pyx_DOCSTR(0)},
2343 {__Pyx_NAMESTR("goto_leaf"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_23goto_leaf, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_8bintrees_7cwalker_7cWalker_22goto_leaf)},
2344 {__Pyx_NAMESTR("has_child"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_25has_child, METH_O, __Pyx_DOCSTR(0)},
2345 {__Pyx_NAMESTR("down"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_27down, METH_O, __Pyx_DOCSTR(0)},
2346 {__Pyx_NAMESTR("go_left"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_29go_left, METH_NOARGS, __Pyx_DOCSTR(0)},
2347 {__Pyx_NAMESTR("go_right"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_31go_right, METH_NOARGS, __Pyx_DOCSTR(0)},
2348 {__Pyx_NAMESTR("has_left"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_33has_left, METH_NOARGS, __Pyx_DOCSTR(0)},
2349 {__Pyx_NAMESTR("has_right"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_35has_right, METH_NOARGS, __Pyx_DOCSTR(0)},
2350 {__Pyx_NAMESTR("succ_item"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_37succ_item, METH_O, __Pyx_DOCSTR(__pyx_doc_8bintrees_7cwalker_7cWalker_36succ_item)},
2351 {__Pyx_NAMESTR("prev_item"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_39prev_item, METH_O, __Pyx_DOCSTR(__pyx_doc_8bintrees_7cwalker_7cWalker_38prev_item)},
2352 {__Pyx_NAMESTR("floor_item"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_41floor_item, METH_O, __Pyx_DOCSTR(__pyx_doc_8bintrees_7cwalker_7cWalker_40floor_item)},
2353 {__Pyx_NAMESTR("ceiling_item"), (PyCFunction)__pyx_pw_8bintrees_7cwalker_7cWalker_43ceiling_item, METH_O, __Pyx_DOCSTR(__pyx_doc_8bintrees_7cwalker_7cWalker_42ceiling_item)},
2357 static PyNumberMethods __pyx_tp_as_number_cWalker = {
2361 #if PY_MAJOR_VERSION < 3
2377 #if PY_MAJOR_VERSION < 3
2381 #if PY_MAJOR_VERSION < 3
2387 #if PY_MAJOR_VERSION < 3
2390 #if PY_MAJOR_VERSION < 3
2393 0, /*nb_inplace_add*/
2394 0, /*nb_inplace_subtract*/
2395 0, /*nb_inplace_multiply*/
2396 #if PY_MAJOR_VERSION < 3
2397 0, /*nb_inplace_divide*/
2399 0, /*nb_inplace_remainder*/
2400 0, /*nb_inplace_power*/
2401 0, /*nb_inplace_lshift*/
2402 0, /*nb_inplace_rshift*/
2403 0, /*nb_inplace_and*/
2404 0, /*nb_inplace_xor*/
2405 0, /*nb_inplace_or*/
2406 0, /*nb_floor_divide*/
2407 0, /*nb_true_divide*/
2408 0, /*nb_inplace_floor_divide*/
2409 0, /*nb_inplace_true_divide*/
2410 #if PY_VERSION_HEX >= 0x02050000
2415 static PySequenceMethods __pyx_tp_as_sequence_cWalker = {
2424 0, /*sq_inplace_concat*/
2425 0, /*sq_inplace_repeat*/
2428 static PyMappingMethods __pyx_tp_as_mapping_cWalker = {
2431 0, /*mp_ass_subscript*/
2434 static PyBufferProcs __pyx_tp_as_buffer_cWalker = {
2435 #if PY_MAJOR_VERSION < 3
2436 0, /*bf_getreadbuffer*/
2438 #if PY_MAJOR_VERSION < 3
2439 0, /*bf_getwritebuffer*/
2441 #if PY_MAJOR_VERSION < 3
2442 0, /*bf_getsegcount*/
2444 #if PY_MAJOR_VERSION < 3
2445 0, /*bf_getcharbuffer*/
2447 #if PY_VERSION_HEX >= 0x02060000
2450 #if PY_VERSION_HEX >= 0x02060000
2451 0, /*bf_releasebuffer*/
2455 static PyTypeObject __pyx_type_8bintrees_7cwalker_cWalker = {
2456 PyVarObject_HEAD_INIT(0, 0)
2457 __Pyx_NAMESTR("bintrees.cwalker.cWalker"), /*tp_name*/
2458 sizeof(struct __pyx_obj_8bintrees_7cwalker_cWalker), /*tp_basicsize*/
2460 __pyx_tp_dealloc_8bintrees_7cwalker_cWalker, /*tp_dealloc*/
2464 #if PY_MAJOR_VERSION < 3
2470 &__pyx_tp_as_number_cWalker, /*tp_as_number*/
2471 &__pyx_tp_as_sequence_cWalker, /*tp_as_sequence*/
2472 &__pyx_tp_as_mapping_cWalker, /*tp_as_mapping*/
2478 &__pyx_tp_as_buffer_cWalker, /*tp_as_buffer*/
2479 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
2483 0, /*tp_richcompare*/
2484 0, /*tp_weaklistoffset*/
2487 __pyx_methods_8bintrees_7cwalker_cWalker, /*tp_methods*/
2494 0, /*tp_dictoffset*/
2497 __pyx_tp_new_8bintrees_7cwalker_cWalker, /*tp_new*/
2503 0, /*tp_subclasses*/
2506 #if PY_VERSION_HEX >= 0x02060000
2507 0, /*tp_version_tag*/
2511 static PyMethodDef __pyx_methods[] = {
2515 #if PY_MAJOR_VERSION >= 3
2516 static struct PyModuleDef __pyx_moduledef = {
2517 PyModuleDef_HEAD_INIT,
2518 __Pyx_NAMESTR("cwalker"),
2521 __pyx_methods /* m_methods */,
2522 NULL, /* m_reload */
2523 NULL, /* m_traverse */
2529 static __Pyx_StringTabEntry __pyx_string_tab[] = {
2530 {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
2531 {&__pyx_n_s__IndexError, __pyx_k__IndexError, sizeof(__pyx_k__IndexError), 0, 0, 1, 1},
2532 {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
2533 {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
2534 {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
2535 {&__pyx_n_s__is_valid, __pyx_k__is_valid, sizeof(__pyx_k__is_valid), 0, 0, 1, 1},
2536 {&__pyx_n_s__item, __pyx_k__item, sizeof(__pyx_k__item), 0, 0, 1, 1},
2537 {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1},
2538 {&__pyx_n_s__pop, __pyx_k__pop, sizeof(__pyx_k__pop), 0, 0, 1, 1},
2539 {&__pyx_n_s__property, __pyx_k__property, sizeof(__pyx_k__property), 0, 0, 1, 1},
2540 {&__pyx_n_s__push, __pyx_k__push, sizeof(__pyx_k__push), 0, 0, 1, 1},
2541 {&__pyx_n_s__reset, __pyx_k__reset, sizeof(__pyx_k__reset), 0, 0, 1, 1},
2542 {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1},
2543 {0, 0, 0, 0, 0, 0, 0}
2545 static int __Pyx_InitCachedBuiltins(void) {
2546 __pyx_builtin_property = __Pyx_GetName(__pyx_b, __pyx_n_s__property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2547 __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2548 __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2554 static int __Pyx_InitCachedConstants(void) {
2555 __Pyx_RefNannyDeclarations
2556 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
2558 /* "bintrees\cwalker.pyx":65
2560 * if stack_is_empty(self.stack) != 0:
2561 * raise IndexError('pop(): stack is empty') # <<<<<<<<<<<<<<
2562 * self.node = stack_pop(self.stack)
2565 __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2566 __Pyx_GOTREF(__pyx_k_tuple_2);
2567 __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
2568 PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_kp_s_1));
2569 __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
2570 __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));
2571 __Pyx_RefNannyFinishContext();
2574 __Pyx_RefNannyFinishContext();
2578 static int __Pyx_InitGlobals(void) {
2579 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
2585 #if PY_MAJOR_VERSION < 3
2586 PyMODINIT_FUNC initcwalker(void); /*proto*/
2587 PyMODINIT_FUNC initcwalker(void)
2589 PyMODINIT_FUNC PyInit_cwalker(void); /*proto*/
2590 PyMODINIT_FUNC PyInit_cwalker(void)
2593 PyObject *__pyx_t_1 = NULL;
2594 PyObject *__pyx_t_2 = NULL;
2595 __Pyx_RefNannyDeclarations
2597 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
2598 if (!__Pyx_RefNanny) {
2600 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
2601 if (!__Pyx_RefNanny)
2602 Py_FatalError("failed to import 'refnanny' module");
2605 __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_cwalker(void)", 0);
2606 if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2607 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2608 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2609 #ifdef __Pyx_CyFunction_USED
2610 if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2612 #ifdef __Pyx_FusedFunction_USED
2613 if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2615 #ifdef __Pyx_Generator_USED
2616 if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2618 /*--- Library function declarations ---*/
2619 /*--- Threads initialization code ---*/
2620 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
2621 #ifdef WITH_THREAD /* Python build with threading support? */
2622 PyEval_InitThreads();
2625 /*--- Module creation code ---*/
2626 #if PY_MAJOR_VERSION < 3
2627 __pyx_m = Py_InitModule4(__Pyx_NAMESTR("cwalker"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
2629 __pyx_m = PyModule_Create(&__pyx_moduledef);
2631 if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2632 #if PY_MAJOR_VERSION >= 3
2634 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2635 if (!PyDict_GetItemString(modules, "bintrees.cwalker")) {
2636 if (unlikely(PyDict_SetItemString(modules, "bintrees.cwalker", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2640 __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2641 #if CYTHON_COMPILING_IN_PYPY
2644 if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
2645 /*--- Initialize various global constants etc. ---*/
2646 if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2647 if (__pyx_module_is_main_bintrees__cwalker) {
2648 if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
2650 /*--- Builtin init code ---*/
2651 if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2652 /*--- Constants init code ---*/
2653 if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2654 /*--- Global init code ---*/
2655 /*--- Variable export code ---*/
2656 /*--- Function export code ---*/
2657 /*--- Type init code ---*/
2658 __pyx_vtabptr_8bintrees_7cwalker_cWalker = &__pyx_vtable_8bintrees_7cwalker_cWalker;
2659 __pyx_vtable_8bintrees_7cwalker_cWalker.set_tree = (void (*)(struct __pyx_obj_8bintrees_7cwalker_cWalker *, node_t *))__pyx_f_8bintrees_7cwalker_7cWalker_set_tree;
2660 __pyx_vtable_8bintrees_7cwalker_cWalker.reset = (PyObject *(*)(struct __pyx_obj_8bintrees_7cwalker_cWalker *, int __pyx_skip_dispatch))__pyx_f_8bintrees_7cwalker_7cWalker_reset;
2661 __pyx_vtable_8bintrees_7cwalker_cWalker.push = (PyObject *(*)(struct __pyx_obj_8bintrees_7cwalker_cWalker *, int __pyx_skip_dispatch))__pyx_f_8bintrees_7cwalker_7cWalker_push;
2662 __pyx_vtable_8bintrees_7cwalker_cWalker.pop = (PyObject *(*)(struct __pyx_obj_8bintrees_7cwalker_cWalker *, int __pyx_skip_dispatch))__pyx_f_8bintrees_7cwalker_7cWalker_pop;
2663 if (PyType_Ready(&__pyx_type_8bintrees_7cwalker_cWalker) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2664 if (__Pyx_SetVtable(__pyx_type_8bintrees_7cwalker_cWalker.tp_dict, __pyx_vtabptr_8bintrees_7cwalker_cWalker) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2665 if (__Pyx_SetAttrString(__pyx_m, "cWalker", (PyObject *)&__pyx_type_8bintrees_7cwalker_cWalker) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2666 __pyx_ptype_8bintrees_7cwalker_cWalker = &__pyx_type_8bintrees_7cwalker_cWalker;
2667 /*--- Type import code ---*/
2668 /*--- Variable import code ---*/
2669 /*--- Function import code ---*/
2670 /*--- Execution code ---*/
2672 /* "bintrees\cwalker.pyx":32
2675 * def key(self): # <<<<<<<<<<<<<<
2676 * return <object> self.node.key
2679 __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_8bintrees_7cwalker_cWalker, __pyx_n_s__key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2680 __Pyx_GOTREF(__pyx_t_1);
2681 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2682 __Pyx_GOTREF(__pyx_t_2);
2683 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
2684 __Pyx_GIVEREF(__pyx_t_1);
2686 __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2687 __Pyx_GOTREF(__pyx_t_1);
2688 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2689 if (PyDict_SetItem((PyObject *)__pyx_ptype_8bintrees_7cwalker_cWalker->tp_dict, __pyx_n_s__key, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2690 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2691 PyType_Modified(__pyx_ptype_8bintrees_7cwalker_cWalker);
2693 /* "bintrees\cwalker.pyx":36
2696 * def value(self): # <<<<<<<<<<<<<<
2697 * return <object> self.node.value
2700 __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_8bintrees_7cwalker_cWalker, __pyx_n_s__value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2701 __Pyx_GOTREF(__pyx_t_1);
2702 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2703 __Pyx_GOTREF(__pyx_t_2);
2704 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
2705 __Pyx_GIVEREF(__pyx_t_1);
2707 __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2708 __Pyx_GOTREF(__pyx_t_1);
2709 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2710 if (PyDict_SetItem((PyObject *)__pyx_ptype_8bintrees_7cwalker_cWalker->tp_dict, __pyx_n_s__value, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2711 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2712 PyType_Modified(__pyx_ptype_8bintrees_7cwalker_cWalker);
2714 /* "bintrees\cwalker.pyx":40
2717 * def item(self): # <<<<<<<<<<<<<<
2718 * return (<object>self.node.key, <object>self.node.value)
2721 __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_8bintrees_7cwalker_cWalker, __pyx_n_s__item); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2722 __Pyx_GOTREF(__pyx_t_1);
2723 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2724 __Pyx_GOTREF(__pyx_t_2);
2725 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
2726 __Pyx_GIVEREF(__pyx_t_1);
2728 __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2729 __Pyx_GOTREF(__pyx_t_1);
2730 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2731 if (PyDict_SetItem((PyObject *)__pyx_ptype_8bintrees_7cwalker_cWalker->tp_dict, __pyx_n_s__item, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2732 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2733 PyType_Modified(__pyx_ptype_8bintrees_7cwalker_cWalker);
2735 /* "bintrees\cwalker.pyx":44
2738 * def is_valid(self): # <<<<<<<<<<<<<<
2739 * return self.node != NULL
2742 __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_8bintrees_7cwalker_cWalker, __pyx_n_s__is_valid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2743 __Pyx_GOTREF(__pyx_t_1);
2744 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2745 __Pyx_GOTREF(__pyx_t_2);
2746 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
2747 __Pyx_GIVEREF(__pyx_t_1);
2749 __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2750 __Pyx_GOTREF(__pyx_t_1);
2751 __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2752 if (PyDict_SetItem((PyObject *)__pyx_ptype_8bintrees_7cwalker_cWalker->tp_dict, __pyx_n_s__is_valid, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2753 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2754 PyType_Modified(__pyx_ptype_8bintrees_7cwalker_cWalker);
2756 /* "bintrees\cwalker.pyx":1
2757 * #!/usr/bin/env python # <<<<<<<<<<<<<<
2761 __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2762 __Pyx_GOTREF(((PyObject *)__pyx_t_1));
2763 if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2764 __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
2767 __Pyx_XDECREF(__pyx_t_1);
2768 __Pyx_XDECREF(__pyx_t_2);
2770 __Pyx_AddTraceback("init bintrees.cwalker", __pyx_clineno, __pyx_lineno, __pyx_filename);
2771 Py_DECREF(__pyx_m); __pyx_m = 0;
2772 } else if (!PyErr_Occurred()) {
2773 PyErr_SetString(PyExc_ImportError, "init bintrees.cwalker");
2776 __Pyx_RefNannyFinishContext();
2777 #if PY_MAJOR_VERSION < 3
2784 /* Runtime support code */
2786 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
2787 PyObject *m = NULL, *p = NULL;
2789 m = PyImport_ImportModule((char *)modname);
2791 p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
2793 r = PyLong_AsVoidPtr(p);
2797 return (__Pyx_RefNannyAPIStruct *)r;
2799 #endif /* CYTHON_REFNANNY */
2801 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
2803 result = PyObject_GetAttr(dict, name);
2805 if (dict != __pyx_b) {
2807 result = PyObject_GetAttr(__pyx_b, name);
2810 PyErr_SetObject(PyExc_NameError, name);
2816 static void __Pyx_RaiseArgtupleInvalid(
2817 const char* func_name,
2821 Py_ssize_t num_found)
2823 Py_ssize_t num_expected;
2824 const char *more_or_less;
2825 if (num_found < num_min) {
2826 num_expected = num_min;
2827 more_or_less = "at least";
2829 num_expected = num_max;
2830 more_or_less = "at most";
2833 more_or_less = "exactly";
2835 PyErr_Format(PyExc_TypeError,
2836 "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)",
2837 func_name, more_or_less, num_expected,
2838 (num_expected == 1) ? "" : "s", num_found);
2841 static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
2843 const char* function_name,
2848 #if CPYTHON_COMPILING_IN_PYPY
2849 if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
2850 goto invalid_keyword;
2853 while (PyDict_Next(kwdict, &pos, &key, 0)) {
2854 #if PY_MAJOR_VERSION < 3
2855 if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
2857 if (unlikely(!PyUnicode_Check(key)))
2858 goto invalid_keyword_type;
2860 if ((!kw_allowed) && unlikely(key))
2861 goto invalid_keyword;
2863 invalid_keyword_type:
2864 PyErr_Format(PyExc_TypeError,
2865 "%s() keywords must be strings", function_name);
2869 PyErr_Format(PyExc_TypeError,
2870 #if PY_MAJOR_VERSION < 3
2871 "%s() got an unexpected keyword argument '%s'",
2872 function_name, PyString_AsString(key));
2874 "%s() got an unexpected keyword argument '%U'",
2875 function_name, key);
2880 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
2881 #if CYTHON_COMPILING_IN_CPYTHON
2882 PyObject *tmp_type, *tmp_value, *tmp_tb;
2883 PyThreadState *tstate = PyThreadState_GET();
2884 tmp_type = tstate->curexc_type;
2885 tmp_value = tstate->curexc_value;
2886 tmp_tb = tstate->curexc_traceback;
2887 tstate->curexc_type = type;
2888 tstate->curexc_value = value;
2889 tstate->curexc_traceback = tb;
2890 Py_XDECREF(tmp_type);
2891 Py_XDECREF(tmp_value);
2894 PyErr_Restore(type, value, tb);
2897 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
2898 #if CYTHON_COMPILING_IN_CPYTHON
2899 PyThreadState *tstate = PyThreadState_GET();
2900 *type = tstate->curexc_type;
2901 *value = tstate->curexc_value;
2902 *tb = tstate->curexc_traceback;
2903 tstate->curexc_type = 0;
2904 tstate->curexc_value = 0;
2905 tstate->curexc_traceback = 0;
2907 PyErr_Fetch(type, value, tb);
2911 #if PY_MAJOR_VERSION < 3
2912 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
2913 CYTHON_UNUSED PyObject *cause) {
2915 if (!value || value == Py_None)
2919 if (!tb || tb == Py_None)
2923 if (!PyTraceBack_Check(tb)) {
2924 PyErr_SetString(PyExc_TypeError,
2925 "raise: arg 3 must be a traceback or None");
2929 #if PY_VERSION_HEX < 0x02050000
2930 if (PyClass_Check(type)) {
2932 if (PyType_Check(type)) {
2934 #if CYTHON_COMPILING_IN_PYPY
2940 PyErr_NormalizeException(&type, &value, &tb);
2943 PyErr_SetString(PyExc_TypeError,
2944 "instance exception may not have a separate value");
2948 #if PY_VERSION_HEX < 0x02050000
2949 if (PyInstance_Check(type)) {
2950 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
2955 PyErr_SetString(PyExc_TypeError,
2956 "raise: exception must be an old-style class or instance");
2960 type = (PyObject*) Py_TYPE(type);
2962 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
2963 PyErr_SetString(PyExc_TypeError,
2964 "raise: exception class must be a subclass of BaseException");
2969 __Pyx_ErrRestore(type, value, tb);
2977 #else /* Python 3+ */
2978 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
2979 PyObject* owned_instance = NULL;
2980 if (tb == Py_None) {
2982 } else if (tb && !PyTraceBack_Check(tb)) {
2983 PyErr_SetString(PyExc_TypeError,
2984 "raise: arg 3 must be a traceback or None");
2987 if (value == Py_None)
2989 if (PyExceptionInstance_Check(type)) {
2991 PyErr_SetString(PyExc_TypeError,
2992 "instance exception may not have a separate value");
2996 type = (PyObject*) Py_TYPE(value);
2997 } else if (PyExceptionClass_Check(type)) {
3000 args = PyTuple_New(0);
3001 else if (PyTuple_Check(value)) {
3006 args = PyTuple_Pack(1, value);
3009 owned_instance = PyEval_CallObject(type, args);
3011 if (!owned_instance)
3013 value = owned_instance;
3014 if (!PyExceptionInstance_Check(value)) {
3015 PyErr_Format(PyExc_TypeError,
3016 "calling %R should have returned an instance of "
3017 "BaseException, not %R",
3018 type, Py_TYPE(value));
3022 PyErr_SetString(PyExc_TypeError,
3023 "raise: exception class must be a subclass of BaseException");
3026 if (cause && cause != Py_None) {
3027 PyObject *fixed_cause;
3028 if (PyExceptionClass_Check(cause)) {
3029 fixed_cause = PyObject_CallObject(cause, NULL);
3030 if (fixed_cause == NULL)
3033 else if (PyExceptionInstance_Check(cause)) {
3034 fixed_cause = cause;
3035 Py_INCREF(fixed_cause);
3038 PyErr_SetString(PyExc_TypeError,
3039 "exception causes must derive from "
3043 PyException_SetCause(value, fixed_cause);
3045 PyErr_SetObject(type, value);
3047 PyThreadState *tstate = PyThreadState_GET();
3048 PyObject* tmp_tb = tstate->curexc_traceback;
3051 tstate->curexc_traceback = tb;
3056 Py_XDECREF(owned_instance);
3061 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
3062 const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
3063 const int is_unsigned = neg_one > const_zero;
3064 if (sizeof(unsigned char) < sizeof(long)) {
3065 long val = __Pyx_PyInt_AsLong(x);
3066 if (unlikely(val != (long)(unsigned char)val)) {
3067 if (!unlikely(val == -1 && PyErr_Occurred())) {
3068 PyErr_SetString(PyExc_OverflowError,
3069 (is_unsigned && unlikely(val < 0)) ?
3070 "can't convert negative value to unsigned char" :
3071 "value too large to convert to unsigned char");
3073 return (unsigned char)-1;
3075 return (unsigned char)val;
3077 return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
3080 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
3081 const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
3082 const int is_unsigned = neg_one > const_zero;
3083 if (sizeof(unsigned short) < sizeof(long)) {
3084 long val = __Pyx_PyInt_AsLong(x);
3085 if (unlikely(val != (long)(unsigned short)val)) {
3086 if (!unlikely(val == -1 && PyErr_Occurred())) {
3087 PyErr_SetString(PyExc_OverflowError,
3088 (is_unsigned && unlikely(val < 0)) ?
3089 "can't convert negative value to unsigned short" :
3090 "value too large to convert to unsigned short");
3092 return (unsigned short)-1;
3094 return (unsigned short)val;
3096 return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
3099 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
3100 const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
3101 const int is_unsigned = neg_one > const_zero;
3102 if (sizeof(unsigned int) < sizeof(long)) {
3103 long val = __Pyx_PyInt_AsLong(x);
3104 if (unlikely(val != (long)(unsigned int)val)) {
3105 if (!unlikely(val == -1 && PyErr_Occurred())) {
3106 PyErr_SetString(PyExc_OverflowError,
3107 (is_unsigned && unlikely(val < 0)) ?
3108 "can't convert negative value to unsigned int" :
3109 "value too large to convert to unsigned int");
3111 return (unsigned int)-1;
3113 return (unsigned int)val;
3115 return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
3118 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
3119 const char neg_one = (char)-1, const_zero = 0;
3120 const int is_unsigned = neg_one > const_zero;
3121 if (sizeof(char) < sizeof(long)) {
3122 long val = __Pyx_PyInt_AsLong(x);
3123 if (unlikely(val != (long)(char)val)) {
3124 if (!unlikely(val == -1 && PyErr_Occurred())) {
3125 PyErr_SetString(PyExc_OverflowError,
3126 (is_unsigned && unlikely(val < 0)) ?
3127 "can't convert negative value to char" :
3128 "value too large to convert to char");
3134 return (char)__Pyx_PyInt_AsLong(x);
3137 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
3138 const short neg_one = (short)-1, const_zero = 0;
3139 const int is_unsigned = neg_one > const_zero;
3140 if (sizeof(short) < sizeof(long)) {
3141 long val = __Pyx_PyInt_AsLong(x);
3142 if (unlikely(val != (long)(short)val)) {
3143 if (!unlikely(val == -1 && PyErr_Occurred())) {
3144 PyErr_SetString(PyExc_OverflowError,
3145 (is_unsigned && unlikely(val < 0)) ?
3146 "can't convert negative value to short" :
3147 "value too large to convert to short");
3153 return (short)__Pyx_PyInt_AsLong(x);
3156 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
3157 const int neg_one = (int)-1, const_zero = 0;
3158 const int is_unsigned = neg_one > const_zero;
3159 if (sizeof(int) < sizeof(long)) {
3160 long val = __Pyx_PyInt_AsLong(x);
3161 if (unlikely(val != (long)(int)val)) {
3162 if (!unlikely(val == -1 && PyErr_Occurred())) {
3163 PyErr_SetString(PyExc_OverflowError,
3164 (is_unsigned && unlikely(val < 0)) ?
3165 "can't convert negative value to int" :
3166 "value too large to convert to int");
3172 return (int)__Pyx_PyInt_AsLong(x);
3175 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
3176 const signed char neg_one = (signed char)-1, const_zero = 0;
3177 const int is_unsigned = neg_one > const_zero;
3178 if (sizeof(signed char) < sizeof(long)) {
3179 long val = __Pyx_PyInt_AsLong(x);
3180 if (unlikely(val != (long)(signed char)val)) {
3181 if (!unlikely(val == -1 && PyErr_Occurred())) {
3182 PyErr_SetString(PyExc_OverflowError,
3183 (is_unsigned && unlikely(val < 0)) ?
3184 "can't convert negative value to signed char" :
3185 "value too large to convert to signed char");
3187 return (signed char)-1;
3189 return (signed char)val;
3191 return (signed char)__Pyx_PyInt_AsSignedLong(x);
3194 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
3195 const signed short neg_one = (signed short)-1, const_zero = 0;
3196 const int is_unsigned = neg_one > const_zero;
3197 if (sizeof(signed short) < sizeof(long)) {
3198 long val = __Pyx_PyInt_AsLong(x);
3199 if (unlikely(val != (long)(signed short)val)) {
3200 if (!unlikely(val == -1 && PyErr_Occurred())) {
3201 PyErr_SetString(PyExc_OverflowError,
3202 (is_unsigned && unlikely(val < 0)) ?
3203 "can't convert negative value to signed short" :
3204 "value too large to convert to signed short");
3206 return (signed short)-1;
3208 return (signed short)val;
3210 return (signed short)__Pyx_PyInt_AsSignedLong(x);
3213 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
3214 const signed int neg_one = (signed int)-1, const_zero = 0;
3215 const int is_unsigned = neg_one > const_zero;
3216 if (sizeof(signed int) < sizeof(long)) {
3217 long val = __Pyx_PyInt_AsLong(x);
3218 if (unlikely(val != (long)(signed int)val)) {
3219 if (!unlikely(val == -1 && PyErr_Occurred())) {
3220 PyErr_SetString(PyExc_OverflowError,
3221 (is_unsigned && unlikely(val < 0)) ?
3222 "can't convert negative value to signed int" :
3223 "value too large to convert to signed int");
3225 return (signed int)-1;
3227 return (signed int)val;
3229 return (signed int)__Pyx_PyInt_AsSignedLong(x);
3232 static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
3233 const int neg_one = (int)-1, const_zero = 0;
3234 const int is_unsigned = neg_one > const_zero;
3235 if (sizeof(int) < sizeof(long)) {
3236 long val = __Pyx_PyInt_AsLong(x);
3237 if (unlikely(val != (long)(int)val)) {
3238 if (!unlikely(val == -1 && PyErr_Occurred())) {
3239 PyErr_SetString(PyExc_OverflowError,
3240 (is_unsigned && unlikely(val < 0)) ?
3241 "can't convert negative value to int" :
3242 "value too large to convert to int");
3248 return (int)__Pyx_PyInt_AsLong(x);
3251 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
3252 const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
3253 const int is_unsigned = neg_one > const_zero;
3254 #if PY_VERSION_HEX < 0x03000000
3255 if (likely(PyInt_Check(x))) {
3256 long val = PyInt_AS_LONG(x);
3257 if (is_unsigned && unlikely(val < 0)) {
3258 PyErr_SetString(PyExc_OverflowError,
3259 "can't convert negative value to unsigned long");
3260 return (unsigned long)-1;
3262 return (unsigned long)val;
3265 if (likely(PyLong_Check(x))) {
3267 if (unlikely(Py_SIZE(x) < 0)) {
3268 PyErr_SetString(PyExc_OverflowError,
3269 "can't convert negative value to unsigned long");
3270 return (unsigned long)-1;
3272 return (unsigned long)PyLong_AsUnsignedLong(x);
3274 return (unsigned long)PyLong_AsLong(x);
3278 PyObject *tmp = __Pyx_PyNumber_Int(x);
3279 if (!tmp) return (unsigned long)-1;
3280 val = __Pyx_PyInt_AsUnsignedLong(tmp);
3286 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
3287 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
3288 const int is_unsigned = neg_one > const_zero;
3289 #if PY_VERSION_HEX < 0x03000000
3290 if (likely(PyInt_Check(x))) {
3291 long val = PyInt_AS_LONG(x);
3292 if (is_unsigned && unlikely(val < 0)) {
3293 PyErr_SetString(PyExc_OverflowError,
3294 "can't convert negative value to unsigned PY_LONG_LONG");
3295 return (unsigned PY_LONG_LONG)-1;
3297 return (unsigned PY_LONG_LONG)val;
3300 if (likely(PyLong_Check(x))) {
3302 if (unlikely(Py_SIZE(x) < 0)) {
3303 PyErr_SetString(PyExc_OverflowError,
3304 "can't convert negative value to unsigned PY_LONG_LONG");
3305 return (unsigned PY_LONG_LONG)-1;
3307 return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
3309 return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
3312 unsigned PY_LONG_LONG val;
3313 PyObject *tmp = __Pyx_PyNumber_Int(x);
3314 if (!tmp) return (unsigned PY_LONG_LONG)-1;
3315 val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
3321 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
3322 const long neg_one = (long)-1, const_zero = 0;
3323 const int is_unsigned = neg_one > const_zero;
3324 #if PY_VERSION_HEX < 0x03000000
3325 if (likely(PyInt_Check(x))) {
3326 long val = PyInt_AS_LONG(x);
3327 if (is_unsigned && unlikely(val < 0)) {
3328 PyErr_SetString(PyExc_OverflowError,
3329 "can't convert negative value to long");
3335 if (likely(PyLong_Check(x))) {
3337 if (unlikely(Py_SIZE(x) < 0)) {
3338 PyErr_SetString(PyExc_OverflowError,
3339 "can't convert negative value to long");
3342 return (long)PyLong_AsUnsignedLong(x);
3344 return (long)PyLong_AsLong(x);
3348 PyObject *tmp = __Pyx_PyNumber_Int(x);
3349 if (!tmp) return (long)-1;
3350 val = __Pyx_PyInt_AsLong(tmp);
3356 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
3357 const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
3358 const int is_unsigned = neg_one > const_zero;
3359 #if PY_VERSION_HEX < 0x03000000
3360 if (likely(PyInt_Check(x))) {
3361 long val = PyInt_AS_LONG(x);
3362 if (is_unsigned && unlikely(val < 0)) {
3363 PyErr_SetString(PyExc_OverflowError,
3364 "can't convert negative value to PY_LONG_LONG");
3365 return (PY_LONG_LONG)-1;
3367 return (PY_LONG_LONG)val;
3370 if (likely(PyLong_Check(x))) {
3372 if (unlikely(Py_SIZE(x) < 0)) {
3373 PyErr_SetString(PyExc_OverflowError,
3374 "can't convert negative value to PY_LONG_LONG");
3375 return (PY_LONG_LONG)-1;
3377 return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
3379 return (PY_LONG_LONG)PyLong_AsLongLong(x);
3383 PyObject *tmp = __Pyx_PyNumber_Int(x);
3384 if (!tmp) return (PY_LONG_LONG)-1;
3385 val = __Pyx_PyInt_AsLongLong(tmp);
3391 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
3392 const signed long neg_one = (signed long)-1, const_zero = 0;
3393 const int is_unsigned = neg_one > const_zero;
3394 #if PY_VERSION_HEX < 0x03000000
3395 if (likely(PyInt_Check(x))) {
3396 long val = PyInt_AS_LONG(x);
3397 if (is_unsigned && unlikely(val < 0)) {
3398 PyErr_SetString(PyExc_OverflowError,
3399 "can't convert negative value to signed long");
3400 return (signed long)-1;
3402 return (signed long)val;
3405 if (likely(PyLong_Check(x))) {
3407 if (unlikely(Py_SIZE(x) < 0)) {
3408 PyErr_SetString(PyExc_OverflowError,
3409 "can't convert negative value to signed long");
3410 return (signed long)-1;
3412 return (signed long)PyLong_AsUnsignedLong(x);
3414 return (signed long)PyLong_AsLong(x);
3418 PyObject *tmp = __Pyx_PyNumber_Int(x);
3419 if (!tmp) return (signed long)-1;
3420 val = __Pyx_PyInt_AsSignedLong(tmp);
3426 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
3427 const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
3428 const int is_unsigned = neg_one > const_zero;
3429 #if PY_VERSION_HEX < 0x03000000
3430 if (likely(PyInt_Check(x))) {
3431 long val = PyInt_AS_LONG(x);
3432 if (is_unsigned && unlikely(val < 0)) {
3433 PyErr_SetString(PyExc_OverflowError,
3434 "can't convert negative value to signed PY_LONG_LONG");
3435 return (signed PY_LONG_LONG)-1;
3437 return (signed PY_LONG_LONG)val;
3440 if (likely(PyLong_Check(x))) {
3442 if (unlikely(Py_SIZE(x) < 0)) {
3443 PyErr_SetString(PyExc_OverflowError,
3444 "can't convert negative value to signed PY_LONG_LONG");
3445 return (signed PY_LONG_LONG)-1;
3447 return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
3449 return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
3452 signed PY_LONG_LONG val;
3453 PyObject *tmp = __Pyx_PyNumber_Int(x);
3454 if (!tmp) return (signed PY_LONG_LONG)-1;
3455 val = __Pyx_PyInt_AsSignedLongLong(tmp);
3461 static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
3462 CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) {
3463 PyObject *old_exc, *old_val, *old_tb;
3465 __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
3466 #if PY_MAJOR_VERSION < 3
3467 ctx = PyString_FromString(name);
3469 ctx = PyUnicode_FromString(name);
3471 __Pyx_ErrRestore(old_exc, old_val, old_tb);
3473 PyErr_WriteUnraisable(Py_None);
3475 PyErr_WriteUnraisable(ctx);
3480 static int __Pyx_check_binary_version(void) {
3481 char ctversion[4], rtversion[4];
3482 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
3483 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
3484 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
3486 PyOS_snprintf(message, sizeof(message),
3487 "compiletime version %s of module '%.100s' "
3488 "does not match runtime version %s",
3489 ctversion, __Pyx_MODULE_NAME, rtversion);
3490 #if PY_VERSION_HEX < 0x02050000
3491 return PyErr_Warn(NULL, message);
3493 return PyErr_WarnEx(NULL, message, 1);
3499 static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
3500 #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
3501 PyObject *ob = PyCapsule_New(vtable, 0, 0);
3503 PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
3507 if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
3516 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
3517 int start = 0, mid = 0, end = count - 1;
3518 if (end >= 0 && code_line > entries[end].code_line) {
3521 while (start < end) {
3522 mid = (start + end) / 2;
3523 if (code_line < entries[mid].code_line) {
3525 } else if (code_line > entries[mid].code_line) {
3531 if (code_line <= entries[mid].code_line) {
3537 static PyCodeObject *__pyx_find_code_object(int code_line) {
3538 PyCodeObject* code_object;
3540 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
3543 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3544 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
3547 code_object = __pyx_code_cache.entries[pos].code_object;
3548 Py_INCREF(code_object);
3551 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
3553 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
3554 if (unlikely(!code_line)) {
3557 if (unlikely(!entries)) {
3558 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
3559 if (likely(entries)) {
3560 __pyx_code_cache.entries = entries;
3561 __pyx_code_cache.max_count = 64;
3562 __pyx_code_cache.count = 1;
3563 entries[0].code_line = code_line;
3564 entries[0].code_object = code_object;
3565 Py_INCREF(code_object);
3569 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3570 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
3571 PyCodeObject* tmp = entries[pos].code_object;
3572 entries[pos].code_object = code_object;
3576 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
3577 int new_max = __pyx_code_cache.max_count + 64;
3578 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
3579 __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
3580 if (unlikely(!entries)) {
3583 __pyx_code_cache.entries = entries;
3584 __pyx_code_cache.max_count = new_max;
3586 for (i=__pyx_code_cache.count; i>pos; i--) {
3587 entries[i] = entries[i-1];
3589 entries[pos].code_line = code_line;
3590 entries[pos].code_object = code_object;
3591 __pyx_code_cache.count++;
3592 Py_INCREF(code_object);
3595 #include "compile.h"
3596 #include "frameobject.h"
3597 #include "traceback.h"
3598 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
3599 const char *funcname, int c_line,
3600 int py_line, const char *filename) {
3601 PyCodeObject *py_code = 0;
3602 PyObject *py_srcfile = 0;
3603 PyObject *py_funcname = 0;
3604 #if PY_MAJOR_VERSION < 3
3605 py_srcfile = PyString_FromString(filename);
3607 py_srcfile = PyUnicode_FromString(filename);
3609 if (!py_srcfile) goto bad;
3611 #if PY_MAJOR_VERSION < 3
3612 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3614 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3618 #if PY_MAJOR_VERSION < 3
3619 py_funcname = PyString_FromString(funcname);
3621 py_funcname = PyUnicode_FromString(funcname);
3624 if (!py_funcname) goto bad;
3625 py_code = __Pyx_PyCode_New(
3626 0, /*int argcount,*/
3627 0, /*int kwonlyargcount,*/
3629 0, /*int stacksize,*/
3631 __pyx_empty_bytes, /*PyObject *code,*/
3632 __pyx_empty_tuple, /*PyObject *consts,*/
3633 __pyx_empty_tuple, /*PyObject *names,*/
3634 __pyx_empty_tuple, /*PyObject *varnames,*/
3635 __pyx_empty_tuple, /*PyObject *freevars,*/
3636 __pyx_empty_tuple, /*PyObject *cellvars,*/
3637 py_srcfile, /*PyObject *filename,*/
3638 py_funcname, /*PyObject *name,*/
3639 py_line, /*int firstlineno,*/
3640 __pyx_empty_bytes /*PyObject *lnotab*/
3642 Py_DECREF(py_srcfile);
3643 Py_DECREF(py_funcname);
3646 Py_XDECREF(py_srcfile);
3647 Py_XDECREF(py_funcname);
3650 static void __Pyx_AddTraceback(const char *funcname, int c_line,
3651 int py_line, const char *filename) {
3652 PyCodeObject *py_code = 0;
3653 PyObject *py_globals = 0;
3654 PyFrameObject *py_frame = 0;
3655 py_code = __pyx_find_code_object(c_line ? c_line : py_line);
3657 py_code = __Pyx_CreateCodeObjectForTraceback(
3658 funcname, c_line, py_line, filename);
3659 if (!py_code) goto bad;
3660 __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
3662 py_globals = PyModule_GetDict(__pyx_m);
3663 if (!py_globals) goto bad;
3664 py_frame = PyFrame_New(
3665 PyThreadState_GET(), /*PyThreadState *tstate,*/
3666 py_code, /*PyCodeObject *code,*/
3667 py_globals, /*PyObject *globals,*/
3668 0 /*PyObject *locals*/
3670 if (!py_frame) goto bad;
3671 py_frame->f_lineno = py_line;
3672 PyTraceBack_Here(py_frame);
3674 Py_XDECREF(py_code);
3675 Py_XDECREF(py_frame);
3678 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
3680 #if PY_MAJOR_VERSION < 3
3681 if (t->is_unicode) {
3682 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
3683 } else if (t->intern) {
3684 *t->p = PyString_InternFromString(t->s);
3686 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
3688 #else /* Python 3+ has unicode identifiers */
3689 if (t->is_unicode | t->is_str) {
3691 *t->p = PyUnicode_InternFromString(t->s);
3692 } else if (t->encoding) {
3693 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
3695 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
3698 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
3709 /* Type Conversion Functions */
3711 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
3712 int is_true = x == Py_True;
3713 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
3714 else return PyObject_IsTrue(x);
3717 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
3719 const char *name = NULL;
3720 PyObject *res = NULL;
3721 #if PY_VERSION_HEX < 0x03000000
3722 if (PyInt_Check(x) || PyLong_Check(x))
3724 if (PyLong_Check(x))
3726 return Py_INCREF(x), x;
3727 m = Py_TYPE(x)->tp_as_number;
3728 #if PY_VERSION_HEX < 0x03000000
3729 if (m && m->nb_int) {
3731 res = PyNumber_Int(x);
3733 else if (m && m->nb_long) {
3735 res = PyNumber_Long(x);
3738 if (m && m->nb_int) {
3740 res = PyNumber_Long(x);
3744 #if PY_VERSION_HEX < 0x03000000
3745 if (!PyInt_Check(res) && !PyLong_Check(res)) {
3747 if (!PyLong_Check(res)) {
3749 PyErr_Format(PyExc_TypeError,
3750 "__%s__ returned non-%s (type %.200s)",
3751 name, name, Py_TYPE(res)->tp_name);
3756 else if (!PyErr_Occurred()) {
3757 PyErr_SetString(PyExc_TypeError,
3758 "an integer is required");
3763 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
3765 PyObject* x = PyNumber_Index(b);
3767 ival = PyInt_AsSsize_t(x);
3772 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
3773 #if PY_VERSION_HEX < 0x02050000
3774 if (ival <= LONG_MAX)
3775 return PyInt_FromLong((long)ival);
3777 unsigned char *bytes = (unsigned char *) &ival;
3778 int one = 1; int little = (int)*(unsigned char*)&one;
3779 return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
3782 return PyInt_FromSize_t(ival);
3786 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
3787 unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
3788 if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
3790 } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
3791 PyErr_SetString(PyExc_OverflowError,
3792 "value too large to convert to size_t");
3799 #endif /* Py_PYTHON_H */