Changeset 3424


Ignore:
Timestamp:
Aug 2, 2013, 2:14:03 PM (6 years ago)
Author:
ksherdy
Message:

Added popcount.

Location:
proto/RE/demo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/RE/demo/grep_demo.py

    r3423 r3424  
    186186        Match(lex, matches)
    187187
    188         print str(pablo.popcount(matches))
     188
     189        print pablo.popcount(matches.all_matches)
    189190
    190191        MatchLines1(lex, matches, lines)
     
    192193
    193194        if(options.count):
    194                 pass # CountMatchLines
     195                pablo.popcount(matches.all_matches)
    195196        else:
    196197    # WriteStreamOutput(Output)
  • proto/RE/demo/pablo.py

    r3423 r3424  
    170170        return ~Advance(~0)
    171171
    172 def popcount(strm)
     172def popcount(stream):
    173173        count = 0
    174         while(strm > 0):
    175                 count = count + (strm & 1)
    176                 strm <<= strm
     174        while(stream > 0):
     175                if stream & 1 == 1: count += 1
     176                stream >>= 1
    177177        return count
    178178
Note: See TracChangeset for help on using the changeset viewer.