idep_altab.cxx File Reference

#include "idep_aliastable.h"
#include <string.h>
#include <memory.h>
#include <iostream>
#include <cassert>

Go to the source code of this file.

Classes

struct  idep_AliasTableLink

Enumerations

enum  { DEFAULT_TABLE_SIZE = 521 }

Functions

static unsigned hash (register const char *name)
static char * newStrCpy (const char *oldStr)
std::ostream & operator<< (std::ostream &o, const idep_AliasTable &table)

Enumeration Type Documentation

anonymous enum
Enumerator:
DEFAULT_TABLE_SIZE 

Definition at line 11 of file idep_altab.cxx.

00011 { DEFAULT_TABLE_SIZE = 521 };


Function Documentation

static unsigned hash ( register const char *  name  )  [static]

Definition at line 13 of file idep_altab.cxx.

Referenced by idep_AliasTable::add(), NuCut::AnaVersionHash(), and idep_AliasTable::lookup().

00013                                                        : returns unsigned!
00014 {
00015     register unsigned sum = 1000003; // 1,000,003 is the 78,498th prime number
00016     while (*name) {
00017         sum *= *name++; // integer multiplication is a subroutine on a SPARC
00018     }
00019     return sum; // unsigned ensures positive value for use with (%) operator.
00020 }

static char* newStrCpy ( const char *  oldStr  )  [static]

Definition at line 22 of file idep_altab.cxx.

References size.

00023 {
00024     int size = strlen(oldStr) + 1;
00025     char *newStr = new char[size];
00026     assert(newStr);
00027     memcpy(newStr, oldStr, size);
00028     return newStr;
00029 }

std::ostream& operator<< ( std::ostream &  o,
const idep_AliasTable table 
)

Definition at line 112 of file idep_altab.cxx.

References idep_AliasTableIter::alias(), it, len, idep_AliasTableIter::originalName(), and idep_AliasTableIter::reset().

00113 {
00114     int fieldWidth = 0; 
00115     idep_AliasTableIter it(table);
00116     for (; it; ++it) {
00117         int len = strlen(it.alias());
00118         if (fieldWidth < len) {
00119             fieldWidth = len;
00120         }
00121     }
00122     for (it.reset(); it; ++it) {
00123         o.width(fieldWidth);
00124         o << it.alias() << " -> " << it.originalName() << std::endl;
00125     }
00126     return o;
00127 }


Generated on 16 Apr 2018 for loon by  doxygen 1.6.1