-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
several more features. Need to re-profile soon.
- Loading branch information
Showing
6 changed files
with
109 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package tech.v3.datatype; | ||
|
||
|
||
public final class CharBuffer | ||
{ | ||
public final boolean trimLeading; | ||
public final boolean trimTrailing; | ||
public final boolean nilEmpty; | ||
char[] buffer; | ||
int len; | ||
|
||
public CharBuffer(boolean _trimLeading, boolean _trimTrailing, boolean _nilEmpty) { | ||
trimLeading = _trimLeading; | ||
trimTrailing = _trimTrailing; | ||
nilEmpty = _nilEmpty; | ||
buffer = new char[32]; | ||
len = 0; | ||
} | ||
public final boolean isspace(char val) { | ||
return val == ' ' || val == '\t'; | ||
} | ||
public final void append(char val) { | ||
if(!trimLeading || | ||
len != 0 || | ||
!isspace(val)) { | ||
if (len == buffer.length) { | ||
char[] newbuffer = new char[buffer.length * 2]; | ||
System.arraycopy(buffer, 0, newbuffer, 0, len); | ||
buffer = newbuffer; | ||
} | ||
buffer[len] = val; | ||
++len; | ||
} | ||
} | ||
public final void clear() { len = 0; } | ||
public final int length() { return len; } | ||
public final String toString() { | ||
int strlen = len; | ||
if(len != 0 && trimTrailing) { | ||
int idx = len - 1; | ||
for (; idx >= 0 && isspace(buffer[idx]); --idx); | ||
strlen = idx + 1; | ||
} | ||
if(strlen == 0) { | ||
if(nilEmpty) { | ||
return null; | ||
} | ||
return ""; | ||
} else { | ||
return new String(buffer, 0, strlen); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
id, char, word, bool, boolstr, boolean | ||
1, t, true, true, true, t | ||
2, f, False, true, true, y | ||
3, y, YES, false, false, n | ||
4, n, NO, false, false, f | ||
5, T, positive, true, true, true | ||
6, F, negative, false, false, false | ||
7, Y, yep, true, true, positive | ||
8, N, not, false, false, negative | ||
9, A, pos, false, False, negative | ||
10, z, neg, false, false, negative |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters