Browse Source

tidy namespace saccades

master
Pete McNeil 4 years ago
parent
commit
5b5652e983
2 changed files with 11 additions and 18 deletions
  1. 5
    7
      snf_saccades.cpp
  2. 6
    11
      snf_saccades.hpp

+ 5
- 7
snf_saccades.cpp View File

#include <vector> #include <vector>
#include "snf_saccades.hpp" #include "snf_saccades.hpp"
using namespace std;
bool doesOverlap(unsigned int workingStart, unsigned int testStart, unsigned int workingFinish) { bool doesOverlap(unsigned int workingStart, unsigned int testStart, unsigned int workingFinish) {
return( return(
testStart >= workingStart && testStart >= workingStart &&
testStart <= workingFinish testStart <= workingFinish
); );
} }
vector<saccade> saccades_engine::recall() {
vector<saccade> recollection;
std::vector<saccade> saccades_engine::recall() {
std::vector<saccade> recollection;
int markersSize = markers.size(); int markersSize = markers.size();
if(0 < markersSize) { if(0 < markersSize) {
set<saccade_marker>::iterator i;
std::set<saccade_marker>::iterator i;
recollection.reserve(markers.size()); recollection.reserve(markers.size());
bool isFirstPass = true; bool isFirstPass = true;
unsigned int workingStart = 0; unsigned int workingStart = 0;
void saccades_engine::evoke(saccade s) { void saccades_engine::evoke(saccade s) {
bool stillGrowing = (capacity > engrams.size()); bool stillGrowing = (capacity > engrams.size());
set<saccade_marker>::iterator i;
std::set<saccade_marker>::iterator i;
saccade_marker testMarker(s,0); saccade_marker testMarker(s,0);
i = markers.find(testMarker); i = markers.find(testMarker);
bool isRemembered = (i != markers.end()); bool isRemembered = (i != markers.end());
} }
} }
void saccades_engine::learn(vector<saccade>& experiences) {
void saccades_engine::learn(std::vector<saccade>& experiences) {
for(unsigned int i = 0; i < experiences.size(); i++) { for(unsigned int i = 0; i < experiences.size(); i++) {
evoke(experiences[i]); evoke(experiences[i]);
} }

+ 6
- 11
snf_saccades.hpp View File

// snf_saccades.hpp // snf_saccades.hpp
// Saccades engine adaptation for MessageSniffer // Saccades engine adaptation for MessageSniffer
// Copyright 2014 MicroNeil Research Corporation (www.microneil.com)
// Copyright 2014-2020 MicroNeil Research Corporation (www.microneil.com)
// Licensed to ARM Research Labs for use in Message Sniffer. // Licensed to ARM Research Labs for use in Message Sniffer.
#ifndef _MN_SACCADES_ENGINE
#define _MN_SACCADES_ENGINE
#pragma once
#include <set> #include <set>
#include <vector> #include <vector>
using namespace std;
class saccades_engine; class saccades_engine;
class saccade { class saccade {
friend class saccades_engine; friend class saccades_engine;
class saccades_engine { class saccades_engine {
private: private:
vector<saccade_engram> engrams;
set<saccade_marker> markers;
std::vector<saccade_engram> engrams;
std::set<saccade_marker> markers;
const unsigned int capacity; const unsigned int capacity;
int mostFresh; int mostFresh;
engrams.reserve(capacity); engrams.reserve(capacity);
} }
vector<saccade> recall();
void learn(vector<saccade>& experiences);
std::vector<saccade> recall();
void learn(std::vector<saccade>& experiences);
}; };
#endif

Loading…
Cancel
Save