cawlign 0.0.1
Codon-aware pairwise sequence alignment
Loading...
Searching...
No Matches
stringBuffer.h
1#ifndef __STRINGBUFFER__
2#define __STRINGBUFFER__
3
4#include "alignment.h"
5
6//__________________________________________________________________________________________
7
13
14 char *sData;
15 unsigned long sLength, saLength;
16
17public:
22 StringBuffer(void);
27 ~StringBuffer(void);
28
34 char *getString(void) const { return sData; }
40 void appendChar(const char);
47 void appendBuffer(const char *, const long = -1);
52 void resetString(void);
58 void swap(StringBuffer &);
64 unsigned long length(void) const { return sLength; }
70 void reset_length(unsigned long newL) {
71 if (newL < sLength) {
72 sLength = newL;
73 }
74 }
75
83 char setChar(const long i, const char c) {
84 char oc = sData[i];
85 sData[i] = c;
86 return oc;
87 }
88
95 char getChar(const long i) const { return sData[i]; }
100 void flip (void);
105 void detach (void) { sData = nullptr;}
106
107 static long sbDefaultLength, sbDefaultBoost;
108};
109
110//__________________________________________________________________________________________
111
116class VectorFP {
117
118 cawlign_fp *vData;
119
120 unsigned long vLength, vaLength;
121
122public:
127 VectorFP(void);
132 ~VectorFP(void);
133
139 void appendValue(const cawlign_fp);
146 void appendValues(const cawlign_fp*, long);
153 void storeValue(const cawlign_fp, const unsigned long);
160 cawlign_fp value(const long idx) { return vData[idx]; }
166 unsigned long length(void) const { return vLength; }
172 const cawlign_fp * values (void) {return vData;}
178 cawlign_fp * rvalues (void) {return vData;}
179
180 static long vDefaultLength, vDefaultBoost;
181};
182
183//__________________________________________________________________________________________
184
189class Vector {
190
191 long *vData;
192
193 unsigned long vLength, vaLength;
194
195public:
200 Vector(void);
205 ~Vector(void);
206
212 void appendValue(const long);
218 void appendVector(const Vector &);
225 long extractMin(VectorFP &);
230 void resetVector(void);
236 void remove(const unsigned long);
243 void storeValue(const long, const unsigned long);
250 void storeVector(const Vector &, const unsigned long);
255 void sort(void);
261 void swap(Vector &);
268 long value(const long idx) const;
274 unsigned long length(void) const { return vLength; }
275
276 const long * rvalues (void) const {return vData;}
277
278 static long vDefaultLength, vDefaultBoost;
279};
280
281#endif
A simple string buffer class that allows for dynamic resizing.
Definition stringBuffer.h:12
void swap(StringBuffer &)
Swap the contents of this string buffer with another.
Definition stringBuffer.cc:44
char setChar(const long i, const char c)
Set a character at a specific index.
Definition stringBuffer.h:83
char * getString(void) const
Get the underlying C string.
Definition stringBuffer.h:34
void appendChar(const char)
Append a character to the string buffer.
Definition stringBuffer.cc:84
char getChar(const long i) const
Get a character at a specific index.
Definition stringBuffer.h:95
void reset_length(unsigned long newL)
Reset the length of the string buffer.
Definition stringBuffer.h:70
StringBuffer(void)
Construct a new String Buffer object.
Definition stringBuffer.cc:27
void detach(void)
Detach the underlying C string from the string buffer.
Definition stringBuffer.h:105
void resetString(void)
Reset the string buffer to an empty state.
Definition stringBuffer.cc:136
void flip(void)
Flip the string buffer in place.
Definition stringBuffer.cc:58
void appendBuffer(const char *, const long=-1)
Append a C string to the string buffer.
Definition stringBuffer.cc:106
unsigned long length(void) const
Get the length of the string buffer.
Definition stringBuffer.h:64
~StringBuffer(void)
Destroy the String Buffer object.
Definition stringBuffer.cc:74
A simple vector class for floating point numbers that allows for dynamic resizing.
Definition stringBuffer.h:116
cawlign_fp value(const long idx)
Get a value at a specific index.
Definition stringBuffer.h:160
unsigned long length(void) const
Get the length of the vector.
Definition stringBuffer.h:166
const cawlign_fp * values(void)
Get the underlying C array.
Definition stringBuffer.h:172
~VectorFP(void)
Destroy the VectorFP object.
Definition stringBuffer.cc:377
void storeValue(const cawlign_fp, const unsigned long)
Store a value at a specific index.
Definition stringBuffer.cc:440
VectorFP(void)
Construct a new VectorFP object.
Definition stringBuffer.cc:365
cawlign_fp * rvalues(void)
Get the underlying C array.
Definition stringBuffer.h:178
void appendValue(const cawlign_fp)
Append a value to the vector.
Definition stringBuffer.cc:389
void appendValues(const cawlign_fp *, long)
Append multiple values to the vector.
Definition stringBuffer.cc:410
void appendVector(const Vector &)
Append another vector to this vector.
Definition stringBuffer.cc:211
void storeVector(const Vector &, const unsigned long)
Store another vector at a specific index.
Definition stringBuffer.cc:266
void storeValue(const long, const unsigned long)
Store a value at a specific index.
Definition stringBuffer.cc:227
long extractMin(VectorFP &)
Extract the minimum value from a VectorFP object.
Definition stringBuffer.cc:299
void swap(Vector &)
Swap the contents of this vector with another.
Definition stringBuffer.cc:163
void appendValue(const long)
Append a value to the vector.
Definition stringBuffer.cc:191
void resetVector(void)
Reset the vector to an empty state.
Definition stringBuffer.cc:357
unsigned long length(void) const
Get the length of the vector.
Definition stringBuffer.h:274
Vector(void)
Construct a new Vector object.
Definition stringBuffer.cc:147
~Vector(void)
Destroy the Vector object.
Definition stringBuffer.cc:177
long value(const long idx) const
Get a value at a specific index.
Definition stringBuffer.cc:249
void remove(const unsigned long)
Remove a value at a specific index.
Definition stringBuffer.cc:281
void sort(void)
Sort the vector in place.
Definition stringBuffer.cc:345