int main(){ vector<string> vs; string s; cout << "Strings:\n"; while (getline(cin, s)) { vs.push_back(s); } vector<int> string_lengths = get_lengths(vs); for (int i=0; i<string_lengths.size(); i++) { printf("%s: %d\n", vs[i].c_str(), string_lengths[i]); } Extremes minmax = find_extremes(vs); printf("Shortest: %s\n", minmax.shortest.c_str()); printf("Longest: %s\n", minmax.longest.c_str()); printf("Lexicographically first: %s\n", minmax.lex_first.c_str()); printf("Lexicographically last: %s\n", minmax.lex_last.c_str()); return 0; }
int RVB::init(double p[], int n_args) { float outskip, inskip, rvb_time; outskip = p[0]; inskip = p[1]; m_dur = p[2]; if (m_dur < 0) /* "dur" represents timend */ m_dur = -m_dur - inskip; if (rtsetinput(inskip, this) == -1) { // no input return(DONT_SCHEDULE); } insamps = (int)(m_dur * SR); m_amp = p[3]; if (inputChannels() != 2) return die(name(), "Input must be stereo."); if (outputChannels() != 2) return die(name(), "Output must be stereo."); double Matrix[12][12]; /* Get results of Minc setup calls (space, mikes_on, mikes_off, matrix) */ if (get_rvb_setup_params(Dimensions, Matrix, &rvb_time) == -1) return die(name(), "You must call setup routine `space' first."); /* (perform some initialization that used to be in space.c) */ int meanLength = MFP_samps(SR, Dimensions); // mean delay length for reverb get_lengths(meanLength); /* sets up delay lengths */ set_gains(rvb_time); /* sets gains for filters */ set_random(); /* sets up random variation of delays */ set_allpass(); wire_matrix(Matrix); _skip = (int) (SR / (float) resetval); if (rtsetoutput(outskip, m_dur + rvb_time, this) == -1) return DONT_SCHEDULE; DBG1(printf("nsamps = %d\n", nSamps())); return nSamps(); }
int MBASE::init(double p[], int n_args) { int flag, UseMikes; float outskip, inskip, abs_factor, dummy; double R, T, dist; outskip = p[0]; inskip = p[1]; m_dur = p[2]; if (m_dur < 0) /* "dur" represents timend */ m_dur = -m_dur - inskip; if (rtsetinput(inskip, this) == -1) { // no input return(DONT_SCHEDULE); } insamps = (int)(m_dur * SR); inamp = p[3]; if (inamp < 0) { m_paths = 1; // Dont process secondary paths inamp = -inamp; } /* Get results of Minc setup calls (space, mikes_on, mikes_off, matrix) */ if (get_setup_params(Dimensions, &m_attenParams, &dummy, &abs_factor, &UseMikes, &MikeAngle, &MikePatternFactor) == -1) { return die(name(), "You must call setup routine `space' first."); } // call inst-specific init code if (localInit(p, n_args) == DONT_SCHEDULE) return die(name(), "localInit failed."); if (m_inchan >= inputChannels()) return die(name(), "You asked for channel %d of a %d-channel input file.", m_inchan, inputChannels()); if (inputChannels() == 1) m_inchan = 0; if (outputChannels() != 4) return die(name(), "Output must be 4-channel (2 signal, 2 reverb feed)."); /* (perform some initialization that used to be in space.c) */ int meanLength = MFP_samps(SR, Dimensions); // mean delay length for reverb get_lengths(meanLength); /* sets up delay lengths */ set_gains(); /* sets gains for filters */ set_walls(abs_factor); /* sets wall filts for move routine */ /* flag for use of ear filters */ m_binaural = (!UseMikes && m_dist < 0.8 && m_dist != 0.0); amparray = floc(1); if (amparray) { int amplen = fsize(1); tableset(SR, m_dur, amplen, amptabs); /* controls input dur only */ } /* determine extra run time for this routine before calling rtsetoutput() */ double reflectionDur = 0.0; finishInit(&reflectionDur); m_branch = 0; if (rtsetoutput(outskip, m_dur + reflectionDur, this) == -1) return DONT_SCHEDULE; DBG1(printf("nsamps = %d\n", nSamps())); return nSamps(); }
int BASE::init(double p[], int n_args) { int UseMikes; float outskip, inskip, abs_factor, rvb_time; outskip = p[0]; inskip = p[1]; m_dur = p[2]; if (m_dur < 0) /* "dur" represents timend */ m_dur = -m_dur - inskip; if (rtsetinput(inskip, this) == -1) { // no input return(DONT_SCHEDULE); } insamps = (int)(m_dur * SR); inamp = p[3]; double Matrix[12][12]; /* Get results of Minc setup calls (space, mikes_on, mikes_off, matrix) */ if (get_setup_params(Dimensions, Matrix, &abs_factor, &rvb_time, &UseMikes, &MikeAngle, &MikePatternFactor) == -1) { return die(name(), "You must call setup routine `space' first."); } // call inst-specific init code if (localInit(p, n_args) == DONT_SCHEDULE) { return die(name(), "localInit failed."); } if (m_inchan >= inputChannels()) { return die(name(), "You asked for channel %d of a %d-channel input file.", m_inchan, inputChannels()); } if (inputChannels() == 1) m_inchan = 0; if (outputChannels() != 2) { return die(name(), "Output must be stereo."); } wire_matrix(Matrix); /* (perform some initialization that used to be in space.c) */ int meanLength = MFP_samps(SR, Dimensions); // mean delay length for reverb get_lengths(meanLength); /* sets up delay lengths */ set_gains(rvb_time); /* sets gains for filters */ set_walls(abs_factor); /* sets wall filts for move routine */ set_allpass(); set_random(); /* sets up random variation of delays */ /* flag for use of ear filters */ m_binaural = (!UseMikes && m_dist < 0.8 && m_dist != 0.0); amparray = floc(1); if (amparray) { int amplen = fsize(1); tableset(SR, m_dur, amplen, amptabs); /* controls input dur only */ } else rtcmix_advise(name(), "Setting phrase curve to all 1's."); /* determine extra run time for this routine before calling rtsetoutput() */ double ringdur = 0.0; finishInit(rvb_time, &ringdur); m_branch = 0; if (rtsetoutput(outskip, m_dur + ringdur, this) == -1) return DONT_SCHEDULE; DBG1(printf("nsamps = %d\n", nSamps())); return nSamps(); }