程序代写 package ngordnet.ngrams;

package ngordnet.ngrams;

import java.util.*;
import java.util.ArrayList;

Copyright By PowCoder代写 加微信 powcoder

/** An object for mapping a year number (e.g. 1996) to numerical data. Provides
* utility methods useful for data analysis.
* @author
public class TimeSeries extends TreeMap {
/** Constructs a new empty TimeSeries. */
public TimeSeries() {

/** Creates a copy of TS, but only between STARTYEAR and ENDYEAR,
* inclusive of both end points. */
public TimeSeries(TimeSeries ts, int startYear, int endYear) {
TimeSeries ts_copy = new TimeSeries();
for (int ts_item : ts.keySet()) {
if (startYear <= ts_item && ts_item <= endYear) { ts_copy.put(ts_item, ts.get(ts_item)); /** Returns all years for this TimeSeries (in any order). */ public List years() {
List year = new ArrayList();
year.addAll(this.keySet());
// for (int years: this.keySet()) {
// year.add(years);
// }
return year;

/** Returns all data for this TimeSeries (in any order).
* Must be in the same order as years(). */
public List data() {
List data = new ArrayList();
for (double d: this.keySet()) {
data.add(d);
return data;

/** Returns the yearwise sum of this TimeSeries with the given TS. In other words, for
* each year, sum the data from this TimeSeries with the data from TS. Should return a
* new TimeSeries (does not modify this TimeSeries). */
public TimeSeries plus(TimeSeries ts) {
TimeSeries plus_copy = new TimeSeries();

return null;

/** Returns the quotient of the value for each year this TimeSeries divided by the
* value for the same year in TS. If TS is missing a year that exists in this TimeSeries,
* throw an IllegalArgumentException. If TS has a year that is not in this TimeSeries, ignore it.
* Should return a new TimeSeries (does not modify this TimeSeries). */
public TimeSeries dividedBy(TimeSeries ts) {
return null;

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com