summaryrefslogtreecommitdiffstats
path: root/dev/a3-earthquake/earthquake_database.cc
diff options
context:
space:
mode:
authorKT <tran0563@umn.edu>2021-09-06 19:07:33 -0500
committerKT <tran0563@umn.edu>2021-09-06 19:07:33 -0500
commitcccd3186305915d92b1751dc616979d64116a4aa (patch)
tree5dd4834daef547cd45fc0b643f44a10b581de0ad /dev/a3-earthquake/earthquake_database.cc
parentAdded missing images for the A6 worksheet (diff)
downloadcsci4611-cccd3186305915d92b1751dc616979d64116a4aa.tar
csci4611-cccd3186305915d92b1751dc616979d64116a4aa.tar.gz
csci4611-cccd3186305915d92b1751dc616979d64116a4aa.tar.bz2
csci4611-cccd3186305915d92b1751dc616979d64116a4aa.tar.lz
csci4611-cccd3186305915d92b1751dc616979d64116a4aa.tar.xz
csci4611-cccd3186305915d92b1751dc616979d64116a4aa.tar.zst
csci4611-cccd3186305915d92b1751dc616979d64116a4aa.zip
Upload a1
Diffstat (limited to 'dev/a3-earthquake/earthquake_database.cc')
-rw-r--r--dev/a3-earthquake/earthquake_database.cc77
1 files changed, 0 insertions, 77 deletions
diff --git a/dev/a3-earthquake/earthquake_database.cc b/dev/a3-earthquake/earthquake_database.cc
deleted file mode 100644
index 2c9a822..0000000
--- a/dev/a3-earthquake/earthquake_database.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-/** CSci-4611 Assignment 3: Earthquake
- */
-
-#include <fstream>
-#include <algorithm>
-
-#include "earthquake_database.h"
-
-
-EarthquakeDatabase::EarthquakeDatabase(std::string filename) {
-
- std::ifstream in(filename.c_str());
- std::string line;
- while (getline(in, line)) {
- if (line.size() > 30) {
- Earthquake e(line);
- if (earthquakes.size() == 0) {
- min_mag_ = (float)e.magnitude();
- max_mag_ = (float)e.magnitude();
- }
- if (e.magnitude() > max_mag_) {
- max_mag_ = (float)e.magnitude();
- }
- if (e.magnitude() < min_mag_) {
- min_mag_ = (float)e.magnitude();
- }
- earthquakes.push_back(e);
- }
- }
-}
-
-Earthquake EarthquakeDatabase::earthquake(int index) {
- return earthquakes[index];
-}
-
-int EarthquakeDatabase::min_index() {
- return 250;
-}
-
-int EarthquakeDatabase::max_index() {
- return (int)earthquakes.size() - 1;
-}
-
-int EarthquakeDatabase::FindMostRecentQuake(Date d) {
- double targetSeconds = d.ToSeconds();
- int start = min_index();
- int end = max_index();
- while (start < end-1) {
- int half = (start + end) / 2;
- if (earthquakes[half].date().ToSeconds() > targetSeconds) {
- end = half - 1;
- }
- else {
- start = half;
- }
- }
- if (start == end) {
- return start;
- }
- else {
- if (earthquakes[end].date().ToSeconds() > targetSeconds) {
- return start;
- }
- else {
- return end;
- }
- }
-}
-
-float EarthquakeDatabase::min_magnitude() {
- return min_mag_;
-}
-
-float EarthquakeDatabase::max_magnitude() {
- return max_mag_;
-}
-