Skip to content

Instantly share code, notes, and snippets.

@bmabey
Created June 19, 2015 17:28
Show Gist options
  • Select an option

  • Save bmabey/6b2ea582fd4c8a463af9 to your computer and use it in GitHub Desktop.

Select an option

Save bmabey/6b2ea582fd4c8a463af9 to your computer and use it in GitHub Desktop.

Revisions

  1. bmabey created this gist Jun 19, 2015.
    11 changes: 11 additions & 0 deletions output.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    19 changes: 19 additions & 0 deletions remove.pyx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    # distutils: language=c++

    from libcpp.vector cimport vector

    cdef extern from "<algorithm>" namespace "std":
    iter std_find "std::find" [iter, T](iter first, iter last, const T& val)

    cdef void remove(vector[int] vect, int elem):
    vect.erase(std_find[vector[int].iterator, int](vect.begin(), vect.end(), elem))

    def blah():
    cdef vector[int] vect
    cdef int i
    for i in range(10):
    vect.push_back(i)
    for i in range(10):
    print vect[i]
    remove(vect, i)
    return vect