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
7e00f43e
Commit
7e00f43e
authored
Mar 10, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed old array multi-implementation files now that it's all merged into
the one implementation.
parent
fb266ade
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
0 additions
and
636 deletions
+0
-636
array_expand_1.h
dlib/array/array_expand_1.h
+0
-170
array_expand_abstract.h
dlib/array/array_expand_abstract.h
+0
-126
array_expand_c.h
dlib/array/array_expand_c.h
+0
-139
array_kernel_1.h
dlib/array/array_kernel_1.h
+0
-0
array_sort_1.h
dlib/array/array_sort_1.h
+0
-77
array_sort_2.h
dlib/array/array_sort_2.h
+0
-65
array_sort_abstract.h
dlib/array/array_sort_abstract.h
+0
-59
No files found.
dlib/array/array_expand_1.h
deleted
100644 → 0
View file @
fb266ade
// Copyright (C) 2006 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_ARRAY_EXPANd_1_
#define DLIB_ARRAY_EXPANd_1_
#include "array_expand_abstract.h"
namespace
dlib
{
template
<
typename
array_base
>
class
array_expand_1
:
public
array_base
{
typedef
typename
array_base
::
type
T
;
public
:
void
resize
(
unsigned
long
new_size
);
const
T
&
back
(
)
const
;
T
&
back
(
);
void
pop_back
(
);
void
pop_back
(
T
&
item
);
void
push_back
(
T
&
item
);
};
template
<
typename
array_base
>
inline
void
swap
(
array_expand_1
<
array_base
>&
a
,
array_expand_1
<
array_base
>&
b
)
{
a
.
swap
(
b
);
}
/*!
provides a global swap function
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
void
array_expand_1
<
array_base
>::
resize
(
unsigned
long
new_size
)
{
if
(
this
->
max_size
()
<
new_size
)
{
array_base
temp
;
temp
.
set_max_size
(
new_size
);
temp
.
set_size
(
new_size
);
for
(
unsigned
long
i
=
0
;
i
<
this
->
size
();
++
i
)
{
exchange
((
*
this
)[
i
],
temp
[
i
]);
}
temp
.
swap
(
*
this
);
}
else
{
this
->
set_size
(
new_size
);
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
typename
array_base
::
type
&
array_expand_1
<
array_base
>::
back
(
)
{
return
(
*
this
)[
this
->
size
()
-
1
];
}
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
const
typename
array_base
::
type
&
array_expand_1
<
array_base
>::
back
(
)
const
{
return
(
*
this
)[
this
->
size
()
-
1
];
}
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
void
array_expand_1
<
array_base
>::
pop_back
(
typename
array_base
::
type
&
item
)
{
exchange
(
item
,(
*
this
)[
this
->
size
()
-
1
]);
this
->
set_size
(
this
->
size
()
-
1
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
void
array_expand_1
<
array_base
>::
pop_back
(
)
{
this
->
set_size
(
this
->
size
()
-
1
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
void
array_expand_1
<
array_base
>::
push_back
(
typename
array_base
::
type
&
item
)
{
if
(
this
->
max_size
()
==
this
->
size
())
{
// double the size of the array
array_base
temp
;
temp
.
set_max_size
(
this
->
size
()
*
2
+
1
);
temp
.
set_size
(
this
->
size
()
+
1
);
for
(
unsigned
long
i
=
0
;
i
<
this
->
size
();
++
i
)
{
exchange
((
*
this
)[
i
],
temp
[
i
]);
}
exchange
(
item
,
temp
[
temp
.
size
()
-
1
]);
temp
.
swap
(
*
this
);
}
else
{
this
->
set_size
(
this
->
size
()
+
1
);
exchange
(
item
,(
*
this
)[
this
->
size
()
-
1
]);
}
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_ARRAY_EXPANd_1_
dlib/array/array_expand_abstract.h
deleted
100644 → 0
View file @
fb266ade
// Copyright (C) 2006 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_ARRAY_EXPANd_ABSTRACT_
#ifdef DLIB_ARRAY_EXPANd_ABSTRACT_
#include "array_kernel_abstract.h"
namespace
dlib
{
template
<
typename
array_base
>
class
array_expand
:
public
array_base
{
/*!
REQUIREMENTS ON ARRAY_BASE
must be an implementation of array/array_kernel_abstract.h
POINTERS AND REFERENCES
resize() may invalidate pointers and references to internal data.
WHAT THIS EXTENSION DOES FOR ARRAY
This extension gives an array the ability to expand its size() beyond
its max_size() without clearing out all its elements. It also adds
a std::vector style push/pop back set of functions.
!*/
typedef
typename
array_base
::
type
T
;
public
:
void
resize
(
unsigned
long
new_size
);
/*!
ensures
- #size() == new_size
- #max_size() == max(new_size,max_size())
- for all i < size() && i < new_size:
- #(*this)[i] == (*this)[i]
(i.e. All the original elements of *this which were at index
values less than new_size are unmodified.)
- for all valid i >= size():
- #(*this)[i] has an undefined value
(i.e. any new elements of the array have an undefined value)
throws
- std::bad_alloc or any exception thrown by T's constructor.
If an exception is thrown then it has no effect on *this.
!*/
const
T
&
back
(
)
const
;
/*!
requires
- size() != 0
ensures
- returns a const reference to (*this)[size()-1]
!*/
T
&
back
(
);
/*!
requires
- size() != 0
ensures
- returns a non-const reference to (*this)[size()-1]
!*/
void
pop_back
(
T
&
item
);
/*!
requires
- size() != 0
ensures
- #size() == size() - 1
- swaps (*this)[size()-1] into item
- All elements with an index less than size()-1 are
unmodified by this operation.
!*/
void
pop_back
(
);
/*!
requires
- size() != 0
ensures
- #size() == size() - 1
- All elements with an index less than size()-1 are
unmodified by this operation.
!*/
void
push_back
(
T
&
item
);
/*!
ensures
- #size() == size()+1
- swaps item into (*this)[#size()-1]
- #back() == item
- #item has some undefined value (whatever happens to
get swapped out of the array)
throws
- std::bad_alloc or any exception thrown by T's constructor.
If an exception is thrown then it has no effect on *this.
!*/
};
template
<
typename
array_base
>
inline
void
swap
(
array_expand
<
array_base
>&
a
,
array_expand
<
array_base
>&
b
)
{
a
.
swap
(
b
);
}
/*!
provides a global swap function
!*/
}
#endif // DLIB_ARRAY_EXPANd_ABSTRACT_
dlib/array/array_expand_c.h
deleted
100644 → 0
View file @
fb266ade
// Copyright (C) 2008 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_ARRAY_EXPAND_C_
#define DLIB_ARRAY_EXPAND_C_
#include "array_expand_abstract.h"
#include "../algs.h"
#include "../assert.h"
namespace
dlib
{
template
<
typename
array_base
>
class
array_expand_c
:
public
array_base
{
typedef
typename
array_base
::
type
T
;
public
:
const
T
&
back
(
)
const
;
T
&
back
(
);
void
pop_back
(
);
void
pop_back
(
T
&
item
);
};
template
<
typename
array_base
>
inline
void
swap
(
array_expand_c
<
array_base
>&
a
,
array_expand_c
<
array_base
>&
b
)
{
a
.
swap
(
b
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
typename
array_base
::
type
&
array_expand_c
<
array_base
>::
back
(
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
size
()
>
0
,
"
\t
T& array_expand::back()"
<<
"
\n\t
size() must be bigger than 0"
<<
"
\n\t
size(): "
<<
this
->
size
()
<<
"
\n\t
this: "
<<
this
);
// call the real function
return
array_base
::
back
();
}
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
const
typename
array_base
::
type
&
array_expand_c
<
array_base
>::
back
(
)
const
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
size
()
>
0
,
"
\t
const T& array_expand::back()"
<<
"
\n\t
size() must be bigger than 0"
<<
"
\n\t
size(): "
<<
this
->
size
()
<<
"
\n\t
this: "
<<
this
);
// call the real function
return
array_base
::
back
();
}
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
void
array_expand_c
<
array_base
>::
pop_back
(
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
size
()
>
0
,
"
\t
void array_expand::pop_back()"
<<
"
\n\t
size() must be bigger than 0"
<<
"
\n\t
size(): "
<<
this
->
size
()
<<
"
\n\t
this: "
<<
this
);
// call the real function
return
array_base
::
pop_back
();
}
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
void
array_expand_c
<
array_base
>::
pop_back
(
typename
array_base
::
type
&
item
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
size
()
>
0
,
"
\t
void array_expand::pop_back()"
<<
"
\n\t
size() must be bigger than 0"
<<
"
\n\t
size(): "
<<
this
->
size
()
<<
"
\n\t
this: "
<<
this
);
// call the real function
return
array_base
::
pop_back
(
item
);
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_ARRAY_EXPAND_C_
dlib/array/array_kernel_1.h
deleted
100644 → 0
View file @
fb266ade
This diff is collapsed.
Click to expand it.
dlib/array/array_sort_1.h
deleted
100644 → 0
View file @
fb266ade
// Copyright (C) 2003 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_ARRAY_SORt_1_
#define DLIB_ARRAY_SORt_1_
#include "array_sort_abstract.h"
#include "../algs.h"
#include "../sort.h"
namespace
dlib
{
template
<
typename
array_base
>
class
array_sort_1
:
public
array_base
{
typedef
typename
array_base
::
type
T
;
public
:
/*!
this is a median of three version of the QuickSort algorithm and
it swaps the entire array into a temporary C style array and sorts that and
this uses the dlib::qsort_array function
!*/
void
sort
(
);
};
template
<
typename
array_base
>
inline
void
swap
(
array_sort_1
<
array_base
>&
a
,
array_sort_1
<
array_base
>&
b
)
{
a
.
swap
(
b
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
void
array_sort_1
<
array_base
>::
sort
(
)
{
if
(
this
->
size
()
>
1
)
{
T
*
temp
=
new
T
[
this
->
size
()];
for
(
unsigned
long
i
=
0
;
i
<
this
->
size
();
++
i
)
exchange
(
temp
[
i
],(
*
this
)[
i
]);
// call the quick sort function for arrays that is in algs.h
dlib
::
qsort_array
(
temp
,
0
,
this
->
size
()
-
1
);
for
(
unsigned
long
i
=
0
;
i
<
this
->
size
();
++
i
)
exchange
((
*
this
)[
i
],
temp
[
i
]);
delete
[]
temp
;
}
this
->
reset
();
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_ARRAY_SORt_1_
dlib/array/array_sort_2.h
deleted
100644 → 0
View file @
fb266ade
// Copyright (C) 2003 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_ARRAY_SORt_2_
#define DLIB_ARRAY_SORt_2_
#include "array_sort_abstract.h"
#include "../algs.h"
#include "../sort.h"
namespace
dlib
{
template
<
typename
array_base
>
class
array_sort_2
:
public
array_base
{
public
:
/*!
this is a median of three version of the QuickSort algorithm and
this uses the dlib::qsort_array function
!*/
void
sort
(
);
};
template
<
typename
array_base
>
inline
void
swap
(
array_sort_2
<
array_base
>&
a
,
array_sort_2
<
array_base
>&
b
)
{
a
.
swap
(
b
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
array_base
>
void
array_sort_2
<
array_base
>::
sort
(
)
{
if
(
this
->
size
()
>
1
)
{
// call the quick sort function for arrays that is in algs.h
dlib
::
qsort_array
(
*
this
,
0
,
this
->
size
()
-
1
);
}
this
->
reset
();
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_ARRAY_SORt_2_
dlib/array/array_sort_abstract.h
deleted
100644 → 0
View file @
fb266ade
// Copyright (C) 2003 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_ARRAY_SORt_ABSTRACT_
#ifdef DLIB_ARRAY_SORt_ABSTRACT_
#include "array_kernel_abstract.h"
namespace
dlib
{
template
<
typename
array_base
>
class
array_sort
:
public
array_base
{
/*!
REQUIREMENTS ON ARRAY_BASE
- must be an implementation of array/array_kernel_abstract.h
- array_base::type must be a type with that is comparable via operator<
POINTERS AND REFERENCES
sort() may invalidate pointers and references to internal data.
WHAT THIS EXTENSION DOES FOR ARRAY
This gives an array the ability to sort its contents by calling sort().
!*/
public
:
void
sort
(
);
/*!
ensures
- for all elements in #*this the ith element is <= the i+1 element
- #at_start() == true
throws
- std::bad_alloc or any exception thrown by T's constructor
data may be lost if sort() throws
!*/
};
template
<
typename
array_base
>
inline
void
swap
(
array_sort
<
array_base
>&
a
,
array_sort
<
array_base
>&
b
)
{
a
.
swap
(
b
);
}
/*!
provides a global swap function
!*/
}
#endif // DLIB_ARRAY_SORt_ABSTRACT_
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