Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
b0a14513
Commit
b0a14513
authored
May 21, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added range and ranges.
parent
5fb4ee66
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
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)
...
@@ -63,6 +63,20 @@ string array__repr__ (const std::vector<double>& v)
return
sout
.
str
();
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
)
string
pair__str__
(
const
std
::
pair
<
unsigned
long
,
double
>&
p
)
{
{
std
::
ostringstream
sout
;
std
::
ostringstream
sout
;
...
@@ -125,6 +139,25 @@ void bind_basic_types()
...
@@ -125,6 +139,25 @@ void bind_basic_types()
.
def_pickle
(
serialize_pickle
<
type
>
());
.
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
;
typedef
pair
<
unsigned
long
,
double
>
pair_type
;
class_
<
pair_type
>
(
"pair"
,
"This object is used to represent the elements of a sparse_vector."
,
init
<>
()
)
class_
<
pair_type
>
(
"pair"
,
"This object is used to represent the elements of a sparse_vector."
,
init
<>
()
)
.
def
(
init
<
unsigned
long
,
double
>
())
.
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