Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
b0a14513
Commit
b0a14513
authored
May 20, 2013
by
Davis King
Browse files
Added range and ranges.
parent
5fb4ee66
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
tools/python/src/basic.cpp
tools/python/src/basic.cpp
+33
-0
No files found.
tools/python/src/basic.cpp
View file @
b0a14513
...
...
@@ -63,6 +63,20 @@ string array__repr__ (const std::vector<double>& v)
return
sout
.
str
();
}
string
range__str__
(
const
std
::
pair
<
unsigned
long
,
unsigned
long
>&
p
)
{
std
::
ostringstream
sout
;
sout
<<
p
.
first
<<
": "
<<
p
.
second
;
return
sout
.
str
();
}
string
range__repr__
(
const
std
::
pair
<
unsigned
long
,
unsigned
long
>&
p
)
{
std
::
ostringstream
sout
;
sout
<<
"dlib.range("
<<
p
.
first
<<
", "
<<
p
.
second
<<
")"
;
return
sout
.
str
();
}
string
pair__str__
(
const
std
::
pair
<
unsigned
long
,
double
>&
p
)
{
std
::
ostringstream
sout
;
...
...
@@ -125,6 +139,25 @@ void bind_basic_types()
.
def_pickle
(
serialize_pickle
<
type
>
());
}
typedef
pair
<
unsigned
long
,
unsigned
long
>
range_type
;
class_
<
range_type
>
(
"range"
,
"This object is used to represent a range of elements in an array."
,
init
<>
()
)
.
def
(
init
<
unsigned
long
,
unsigned
long
>
())
.
def_readwrite
(
"begin"
,
&
range_type
::
first
,
"The index of the first element in the range."
)
.
def_readwrite
(
"end"
,
&
range_type
::
second
,
"One past the index of the last element in the range."
)
.
def
(
"__str__"
,
range__str__
)
.
def
(
"__repr__"
,
range__repr__
)
.
def_pickle
(
serialize_pickle
<
range_type
>
());
{
typedef
std
::
vector
<
std
::
pair
<
unsigned
long
,
unsigned
long
>
>
type
;
class_
<
type
>
(
"ranges"
,
"This object is an array of range objects."
)
.
def
(
vector_indexing_suite
<
type
>
())
.
def
(
"clear"
,
&
type
::
clear
)
.
def
(
"resize"
,
resize
<
type
>
)
.
def_pickle
(
serialize_pickle
<
type
>
());
}
typedef
pair
<
unsigned
long
,
double
>
pair_type
;
class_
<
pair_type
>
(
"pair"
,
"This object is used to represent the elements of a sparse_vector."
,
init
<>
()
)
.
def
(
init
<
unsigned
long
,
double
>
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment