Commit 65af5bfb authored by Davis King's avatar Davis King

Added a constructor to array2d that lets you set its size.

parent 6db9eb73
...@@ -143,6 +143,31 @@ namespace dlib ...@@ -143,6 +143,31 @@ namespace dlib
{ {
} }
array2d(
long nr__,
long nc__
) :
nc_(0),
nr_(0),
rows(0),
data(0),
cur(0),
last(0),
at_start_(true)
{
// make sure requires clause is not broken
DLIB_ASSERT((nc__ > 0 && nr__ > 0) ||
(nc__ == 0 && nr__ == 0),
"\t array2d::array2d(long nr__, long nc__)"
<< "\n\t You have to give a non zero nc and nr or just make both zero."
<< "\n\t this: " << this
<< "\n\t nc__: " << nc__
<< "\n\t nr__: " << nr__
);
set_size(nr__,nc__);
}
virtual ~array2d ( virtual ~array2d (
) { clear(); } ) { clear(); }
......
...@@ -124,6 +124,23 @@ namespace dlib ...@@ -124,6 +124,23 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
array2d (
long rows,
long cols
);
/*!
requires
- cols > 0 && rows > 0 or
cols == 0 && rows == 0
ensures
- #nc() == cols
- #nr() == rows
- #at_start() == true
- all elements in this array have initial values for their type
throws
- std::bad_alloc
!*/
virtual ~array2d ( virtual ~array2d (
); );
/*! /*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment