mirror of https://github.com/xfarrow/lasd.git
Update
This commit is contained in:
parent
8f7716bc2d
commit
a6485b86af
|
@ -1,9 +1,9 @@
|
||||||
|
#define MINSIZE 4
|
||||||
namespace lasd {
|
namespace lasd {
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
QueueVec<Data>::QueueVec(){
|
QueueVec<Data>::QueueVec(){
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
rear = 0;
|
rear = 0;
|
||||||
front = 0;
|
front = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[size];
|
||||||
|
@ -146,10 +146,10 @@ ulong QueueVec<Data>::Size() const noexcept{
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void QueueVec<Data>::Clear(){
|
void QueueVec<Data>::Clear(){
|
||||||
if(size!=4){
|
if(size!=MINSIZE){
|
||||||
delete[] Elements;
|
delete[] Elements;
|
||||||
Elements = new Data[4];
|
Elements = new Data[MINSIZE];
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
}
|
}
|
||||||
front = 0;
|
front = 0;
|
||||||
rear = 0;
|
rear = 0;
|
||||||
|
@ -173,7 +173,7 @@ void QueueVec<Data>::Expand(){
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void QueueVec<Data>::Reduce(){
|
void QueueVec<Data>::Reduce(){
|
||||||
if(size<=4) return; // we are not going to have vectors with less than 4 Elements
|
if(size<(MINSIZE*2)) return; // we are not going to have vectors with less than 4 Elements
|
||||||
ulong newsize = (ulong)size/2;
|
ulong newsize = (ulong)size/2;
|
||||||
Data* tmp = new Data[newsize];
|
Data* tmp = new Data[newsize];
|
||||||
ulong current_index = front , i=0;
|
ulong current_index = front , i=0;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
|
#define MINSIZE 4
|
||||||
namespace lasd {
|
namespace lasd {
|
||||||
|
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
// constructors
|
// constructors
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
StackVec<Data>::StackVec(){
|
StackVec<Data>::StackVec(){
|
||||||
size = 4; // default vector is instantiated with 4 cells
|
size = MINSIZE; // default vector is instantiated with 4 cells
|
||||||
stackSize = 0;
|
stackSize = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[size];
|
||||||
}
|
}
|
||||||
|
@ -129,15 +129,15 @@ void StackVec<Data>::Expand(){
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void StackVec<Data>::Reduce(){
|
void StackVec<Data>::Reduce(){
|
||||||
if(size <= 4) return; // we're not going to have vectors with less than 4 cells
|
if(size < (MINSIZE*2)) return; // we're not going to have vectors with less than 4 cells
|
||||||
Vector<Data>::Resize((ulong)size/2);
|
Vector<Data>::Resize((ulong)size/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void StackVec<Data>::Clear(){
|
void StackVec<Data>::Clear(){
|
||||||
delete [] Elements;
|
delete [] Elements;
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
stackSize = 0;
|
stackSize = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[MINSIZE];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
#define MINSIZE 4
|
||||||
namespace lasd {
|
namespace lasd {
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
QueueVec<Data>::QueueVec(){
|
QueueVec<Data>::QueueVec(){
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
rear = 0;
|
rear = 0;
|
||||||
front = 0;
|
front = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[size];
|
||||||
|
@ -146,10 +146,10 @@ ulong QueueVec<Data>::Size() const noexcept{
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void QueueVec<Data>::Clear(){
|
void QueueVec<Data>::Clear(){
|
||||||
if(size!=4){
|
if(size!=MINSIZE){
|
||||||
delete[] Elements;
|
delete[] Elements;
|
||||||
Elements = new Data[4];
|
Elements = new Data[MINSIZE];
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
}
|
}
|
||||||
front = 0;
|
front = 0;
|
||||||
rear = 0;
|
rear = 0;
|
||||||
|
@ -173,7 +173,7 @@ void QueueVec<Data>::Expand(){
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void QueueVec<Data>::Reduce(){
|
void QueueVec<Data>::Reduce(){
|
||||||
if(size<=4) return; // we are not going to have vectors with less than 4 Elements
|
if(size<(MINSIZE*2)) return; // we are not going to have vectors with less than 4 Elements
|
||||||
ulong newsize = (ulong)size/2;
|
ulong newsize = (ulong)size/2;
|
||||||
Data* tmp = new Data[newsize];
|
Data* tmp = new Data[newsize];
|
||||||
ulong current_index = front , i=0;
|
ulong current_index = front , i=0;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
|
#define MINSIZE 4
|
||||||
namespace lasd {
|
namespace lasd {
|
||||||
|
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
// constructors
|
// constructors
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
StackVec<Data>::StackVec(){
|
StackVec<Data>::StackVec(){
|
||||||
size = 4; // default vector is instantiated with 4 cells
|
size = MINSIZE; // default vector is instantiated with 4 cells
|
||||||
stackSize = 0;
|
stackSize = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[size];
|
||||||
}
|
}
|
||||||
|
@ -129,15 +129,15 @@ void StackVec<Data>::Expand(){
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void StackVec<Data>::Reduce(){
|
void StackVec<Data>::Reduce(){
|
||||||
if(size <= 4) return; // we're not going to have vectors with less than 4 cells
|
if(size < (MINSIZE*2)) return; // we're not going to have vectors with less than 4 cells
|
||||||
Vector<Data>::Resize((ulong)size/2);
|
Vector<Data>::Resize((ulong)size/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void StackVec<Data>::Clear(){
|
void StackVec<Data>::Clear(){
|
||||||
delete [] Elements;
|
delete [] Elements;
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
stackSize = 0;
|
stackSize = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[MINSIZE];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
#define MINSIZE 4
|
||||||
namespace lasd {
|
namespace lasd {
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
QueueVec<Data>::QueueVec(){
|
QueueVec<Data>::QueueVec(){
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
rear = 0;
|
rear = 0;
|
||||||
front = 0;
|
front = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[size];
|
||||||
|
@ -146,10 +146,10 @@ ulong QueueVec<Data>::Size() const noexcept{
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void QueueVec<Data>::Clear(){
|
void QueueVec<Data>::Clear(){
|
||||||
if(size!=4){
|
if(size!=MINSIZE){
|
||||||
delete[] Elements;
|
delete[] Elements;
|
||||||
Elements = new Data[4];
|
Elements = new Data[MINSIZE];
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
}
|
}
|
||||||
front = 0;
|
front = 0;
|
||||||
rear = 0;
|
rear = 0;
|
||||||
|
@ -173,7 +173,7 @@ void QueueVec<Data>::Expand(){
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void QueueVec<Data>::Reduce(){
|
void QueueVec<Data>::Reduce(){
|
||||||
if(size<=4) return; // we are not going to have vectors with less than 4 Elements
|
if(size<(MINSIZE*2)) return; // we are not going to have vectors with less than 4 Elements
|
||||||
ulong newsize = (ulong)size/2;
|
ulong newsize = (ulong)size/2;
|
||||||
Data* tmp = new Data[newsize];
|
Data* tmp = new Data[newsize];
|
||||||
ulong current_index = front , i=0;
|
ulong current_index = front , i=0;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
|
#define MINSIZE 4
|
||||||
namespace lasd {
|
namespace lasd {
|
||||||
|
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
// constructors
|
// constructors
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
StackVec<Data>::StackVec(){
|
StackVec<Data>::StackVec(){
|
||||||
size = 4; // default vector is instantiated with 4 cells
|
size = MINSIZE; // default vector is instantiated with 4 cells
|
||||||
stackSize = 0;
|
stackSize = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[size];
|
||||||
}
|
}
|
||||||
|
@ -129,15 +129,15 @@ void StackVec<Data>::Expand(){
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void StackVec<Data>::Reduce(){
|
void StackVec<Data>::Reduce(){
|
||||||
if(size <= 4) return; // we're not going to have vectors with less than 4 cells
|
if(size < (MINSIZE*2)) return; // we're not going to have vectors with less than 4 cells
|
||||||
Vector<Data>::Resize((ulong)size/2);
|
Vector<Data>::Resize((ulong)size/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void StackVec<Data>::Clear(){
|
void StackVec<Data>::Clear(){
|
||||||
delete [] Elements;
|
delete [] Elements;
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
stackSize = 0;
|
stackSize = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[MINSIZE];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
#define MINSIZE 4
|
||||||
namespace lasd {
|
namespace lasd {
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
QueueVec<Data>::QueueVec(){
|
QueueVec<Data>::QueueVec(){
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
rear = 0;
|
rear = 0;
|
||||||
front = 0;
|
front = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[size];
|
||||||
|
@ -146,10 +146,10 @@ ulong QueueVec<Data>::Size() const noexcept{
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void QueueVec<Data>::Clear(){
|
void QueueVec<Data>::Clear(){
|
||||||
if(size!=4){
|
if(size!=MINSIZE){
|
||||||
delete[] Elements;
|
delete[] Elements;
|
||||||
Elements = new Data[4];
|
Elements = new Data[MINSIZE];
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
}
|
}
|
||||||
front = 0;
|
front = 0;
|
||||||
rear = 0;
|
rear = 0;
|
||||||
|
@ -173,7 +173,7 @@ void QueueVec<Data>::Expand(){
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void QueueVec<Data>::Reduce(){
|
void QueueVec<Data>::Reduce(){
|
||||||
if(size<=4) return; // we are not going to have vectors with less than 4 Elements
|
if(size<(MINSIZE*2)) return; // we are not going to have vectors with less than 4 Elements
|
||||||
ulong newsize = (ulong)size/2;
|
ulong newsize = (ulong)size/2;
|
||||||
Data* tmp = new Data[newsize];
|
Data* tmp = new Data[newsize];
|
||||||
ulong current_index = front , i=0;
|
ulong current_index = front , i=0;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
|
#define MINSIZE 4
|
||||||
namespace lasd {
|
namespace lasd {
|
||||||
|
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
// constructors
|
// constructors
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
StackVec<Data>::StackVec(){
|
StackVec<Data>::StackVec(){
|
||||||
size = 4; // default vector is instantiated with 4 cells
|
size = MINSIZE; // default vector is instantiated with 4 cells
|
||||||
stackSize = 0;
|
stackSize = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[size];
|
||||||
}
|
}
|
||||||
|
@ -129,15 +129,15 @@ void StackVec<Data>::Expand(){
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void StackVec<Data>::Reduce(){
|
void StackVec<Data>::Reduce(){
|
||||||
if(size <= 4) return; // we're not going to have vectors with less than 4 cells
|
if(size < (MINSIZE*2)) return; // we're not going to have vectors with less than 4 cells
|
||||||
Vector<Data>::Resize((ulong)size/2);
|
Vector<Data>::Resize((ulong)size/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void StackVec<Data>::Clear(){
|
void StackVec<Data>::Clear(){
|
||||||
delete [] Elements;
|
delete [] Elements;
|
||||||
size = 4;
|
size = MINSIZE;
|
||||||
stackSize = 0;
|
stackSize = 0;
|
||||||
Elements = new Data[size];
|
Elements = new Data[MINSIZE];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue