Ignore:
Timestamp:
Jan 16, 2024, 5:30:58 PM (11 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
06280ad
Parents:
739495a
Message:

Add missing test for string *= and refactor */*= to follow +/+= pattern with string_res.

Location:
libcfa/src/collections
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/collections/string.cfa

    r739495a r38951c31  
    236236// Repetition
    237237
     238void ?*=?(string & s, size_t factor) {
     239    (*s.inner) *= factor;
     240}
     241
    238242string ?*?(const string & s, size_t factor) {
    239     string ret = "";
    240     for (factor) ret += s;
    241     return ret;
    242 }
    243 
    244 void ?*=?(string & s, size_t factor) {
    245     s = s * factor;
     243    string ret = s;
     244    ret *= factor;
     245    return ret;
    246246}
    247247
    248248string ?*?(char c, size_t factor) {
    249249    string ret = c;
    250     return ret * factor;
     250    ret *= factor;
     251    return ret;
    251252}
    252253
    253254string ?*?(const char * s, size_t factor) {
    254255    string ret = s;
    255     return ret * factor;
     256    ret *= factor;
     257    return ret;
    256258}
    257259
  • libcfa/src/collections/string_res.cfa

    r739495a r38951c31  
    642642
    643643
     644///////////////////////////////////////////////////////////////////
     645// Repetition
     646
     647void ?*=?(string_res & s, size_t factor) {
     648    string_res s2 = { s, COPY_VALUE, 0, size(s) };
     649    s = "";
     650    for (factor) s += s2;
     651}
     652
    644653//////////////////////////////////////////////////////////
    645654// Comparisons
  • libcfa/src/collections/string_res.hfa

    r739495a r38951c31  
    136136}
    137137
     138// Repetition
     139void ?*=?(string_res & s, size_t factor);
     140
    138141// Character access
    139142void assignAt(const string_res & s, size_t index, char val);
Note: See TracChangeset for help on using the changeset viewer.