X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2Fdeletebydate%2FDateInfoList.java;fp=tim%2Fprune%2Ffunction%2Fdeletebydate%2FDateInfoList.java;h=979325bb42baa555dd27eb5b92a9ad211fcb05f3;hp=76286675502bc7403ad3f0085fdc789b1cd6b8f8;hb=92dad5df664287acb51728e9ea599f150765d34a;hpb=81843c3d8d0771bf00d0f26034a13aa515465c78 diff --git a/tim/prune/function/deletebydate/DateInfoList.java b/tim/prune/function/deletebydate/DateInfoList.java index 7628667..979325b 100644 --- a/tim/prune/function/deletebydate/DateInfoList.java +++ b/tim/prune/function/deletebydate/DateInfoList.java @@ -24,34 +24,34 @@ public class DateInfoList */ public void addPoint(Date inDate) { + DateInfo currentInfo = null; if (_previousInfo != null && _previousInfo.isSameDate(inDate)) { // found it - _previousInfo.incrementCount(); + currentInfo = _previousInfo; } else { - // loop through list, seeing if date already present - boolean foundDate = false; + // loop through list, to see if date already present for (DateInfo info : _infoList) { if (info.isSameDate(inDate)) { - info.incrementCount(); - _previousInfo = info; - foundDate = true; + currentInfo = info; break; } } // create new info if necessary - if (!foundDate) + if (currentInfo == null) { - _previousInfo = new DateInfo(inDate); - _previousInfo.incrementCount(); - _infoList.add(_previousInfo); + currentInfo = new DateInfo(inDate); + _infoList.add(currentInfo); _hasBeenSorted = false; } + _previousInfo = currentInfo; } + // Now we've identified the current info or created a new one + currentInfo.incrementCount(); } /** @@ -64,18 +64,6 @@ public class DateInfoList _hasBeenSorted = true; } - /** - * not used, can be removed - * @return true if any points without dates were found - */ - public boolean hasDatelessPoints() - { - if (_infoList.isEmpty()) {return false;} - sort(); - DateInfo firstInfo = _infoList.get(0); - return (firstInfo != null && firstInfo.isDateless() && firstInfo.getPointCount() > 0); - } - /** * @return number of entries in the list, including dateless points */