aboutsummaryrefslogtreecommitdiffstats
path: root/csci1913/Java/notes/sequence.java
diff options
context:
space:
mode:
authorRossTheRoss <mstrapp@protonmail.com>2019-11-03 12:01:48 -0600
committerRossTheRoss <mstrapp@protonmail.com>2019-11-03 12:01:48 -0600
commit13945160822dd3d16bdfa7c24abefeffb7a5be61 (patch)
treee589db732231a4d1aac7c450aefa96248ad14616 /csci1913/Java/notes/sequence.java
parentFinish things (diff)
downloadhomework-13945160822dd3d16bdfa7c24abefeffb7a5be61.tar
homework-13945160822dd3d16bdfa7c24abefeffb7a5be61.tar.gz
homework-13945160822dd3d16bdfa7c24abefeffb7a5be61.tar.bz2
homework-13945160822dd3d16bdfa7c24abefeffb7a5be61.tar.lz
homework-13945160822dd3d16bdfa7c24abefeffb7a5be61.tar.xz
homework-13945160822dd3d16bdfa7c24abefeffb7a5be61.tar.zst
homework-13945160822dd3d16bdfa7c24abefeffb7a5be61.zip
?
Diffstat (limited to 'csci1913/Java/notes/sequence.java')
-rw-r--r--csci1913/Java/notes/sequence.java41
1 files changed, 0 insertions, 41 deletions
diff --git a/csci1913/Java/notes/sequence.java b/csci1913/Java/notes/sequence.java
deleted file mode 100644
index ac8f487..0000000
--- a/csci1913/Java/notes/sequence.java
+++ /dev/null
@@ -1,41 +0,0 @@
-class Sequence<Base> {
- private Base[] bases;
- private int count;
-
- public int find (Base base){
- if (base == null) {
- for (int i=0; i<count; i+=1) {
- if (bases[i] == null) {
- return index;
- }
- }
- } else {
- for (int i=0; i<count; i+=1) {
- if (Base.equals(bases[i])) {
- return index;
- }
- }
- } return -1; //Fail case
- }
-//While loop is basically an infinitely nexted series of if statements
- //(It's called loop unrolling)
-//Sometimes the first execution is special (see below)
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append('[');
- if (count > 0) {
- builder.append(bases[0].toString())
- //Add a helper fo the null pointer
- for (int i = 1; i < count; i += 1) {
- builder.append(" ,");
- //Add a helper to not dereference the null pointer
- builder.append(bases[i].toString());
- }
- } builder.append(']')
- return builder.toString();
- }
-//Arrays as sequences
- //Add O(n) needed a copy loop
- //Delete O(n) needed a copy loop - first element
- //Find O(n) used linear search
- //Can we go faster? (Yes, probably) \ No newline at end of file