Ignore:
Timestamp:
05/29/18 16:51:14 (6 years ago)
Author:
Maciej Komosinski
Message:

Code formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/util/usertags.h

    r286 r793  
    4141 */
    4242
    43 template<class ID,class T,int N> class UserTags
     43template<class ID, class T, int N> class UserTags
    4444{
    45 static char reg[N];
    46 T data[N];
    47   public:
    48 UserTags() {memset(data,0,sizeof(data));}
     45        static char reg[N];
     46        T data[N];
     47public:
     48        UserTags() { memset(data, 0, sizeof(data)); }
    4949
    50 /** allocate new id */
    51 static int newID()
    52         { for(int i=1;i<N;i++) if (!reg[i]) {reg[i]=1; return i;}
    53         DB(printf("Warning: UserTags run out of ids!\n"));
    54           return 0; }
    55 static void freeID(int id)
    56         { reg[id]=0; }
    57 T& operator[](int id)
     50        /** allocate new id */
     51        static int newID()
    5852        {
    59         DB(if (!id) printf("Warning: UserTags @ %p is using id=0\n",this);)
    60         return data[id];
     53                for (int i = 1; i < N; i++) if (!reg[i]) { reg[i] = 1; return i; }
     54                DB(printf("Warning: UserTags run out of ids!\n"));
     55                return 0;
    6156        }
    62 operator T() { return data[0]; }
    63 void operator=(T x) { data[0]=x; }
     57        static void freeID(int id)
     58        {
     59                reg[id] = 0;
     60        }
     61        T& operator[](int id)
     62        {
     63                DB(if (!id) printf("Warning: UserTags @ %p is using id=0\n", this);)
     64                        return data[id];
     65        }
     66        operator T() { return data[0]; }
     67        void operator=(T x) { data[0] = x; }
    6468};
    6569
    6670#endif
    67 
    68 
    69 
    70 
    71 
Note: See TracChangeset for help on using the changeset viewer.