From 8e67e9de1b200106bea5a468ac02125954656499 Mon Sep 17 00:00:00 2001 From: kdiverson Date: Fri, 29 Jun 2012 16:07:26 -0400 Subject: [PATCH] cleaned up code --- kruskalwalliscommand.cpp | 13 +++++++++---- kruskalwalliscommand.h | 10 +++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/kruskalwalliscommand.cpp b/kruskalwalliscommand.cpp index 9064f49..76aebe0 100644 --- a/kruskalwalliscommand.cpp +++ b/kruskalwalliscommand.cpp @@ -4,6 +4,7 @@ * * Created on June 26, 2012, 11:06 AM */ + #include "kruskalwalliscommand.h" //********************************************************************************************************************** @@ -186,22 +187,26 @@ void KruskalWallisCommand::assignRank(vector &vec) { while ( it != vec.end() ) { j = rank; oldit = it; - if (!equalvalue(*it, *it+1)) { *it->rank = rank; rank=rank+1; it++; } + if (!equalvalue(*it, *(it+1))) { + (*it).rank = rank; + rank = rank+1; + it++; } else { - while(equalrank(*it, *it+1)) { - j = j + (j+1.0); + while(equalrank(*it, *(it+1))) { + j = j + (j+1); rank++; it++; } numRanks = double (distance(oldit, it)); avgRank = j / numRanks; while(oldit != it) { - *oldit->rank = avgRank; + (*oldit).rank = avgRank; oldit++; } } } + } catch(exception& e) { diff --git a/kruskalwalliscommand.h b/kruskalwalliscommand.h index 1aadb16..e3bf100 100644 --- a/kruskalwalliscommand.h +++ b/kruskalwalliscommand.h @@ -47,11 +47,11 @@ private: - bool comparevalue(const groupRank &a, const groupRank &b) { return a.value < b.value; } - bool equalvalue(const groupRank &a, const groupRank &b) { return a.value == b.value; } - bool comparerank(const groupRank &a, const groupRank &b) { return a.rank < b.rank; } - bool equalrank(const groupRank &a, const groupRank &b) { return a.rank == b.rank; } - bool equalgroup(const groupRank &a, const groupRank &b) { return a.group == b.group; } + static bool comparevalue(const groupRank &a, const groupRank &b) { return a.value < b.value; } + static bool equalvalue(const groupRank &a, const groupRank &b) { return a.value == b.value; } + static bool comparerank(const groupRank &a, const groupRank &b) { return a.rank < b.rank; } + static bool equalrank(const groupRank &a, const groupRank &b) { return a.rank == b.rank; } + static bool equalgroup(const groupRank &a, const groupRank &b) { return a.group == b.group; } }; -- 2.39.2