Click here to Skip to main content
15,900,110 members
Home / Discussions / C#
   

C#

 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus314-Jan-08 23:00
invictus314-Jan-08 23:00 
AnswerRe: Count bitpattern occurences in textstrings Pin
Ajay.k_Singh14-Jan-08 23:11
Ajay.k_Singh14-Jan-08 23:11 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus314-Jan-08 23:29
invictus314-Jan-08 23:29 
GeneralRe: Count bitpattern occurences in textstrings Pin
Russell Jones15-Jan-08 0:02
Russell Jones15-Jan-08 0:02 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus315-Jan-08 0:05
invictus315-Jan-08 0:05 
GeneralRe: Count bitpattern occurences in textstrings Pin
Russell Jones15-Jan-08 0:45
Russell Jones15-Jan-08 0:45 
GeneralRe: Count bitpattern occurences in textstrings [modified] Pin
Luc Pattyn15-Jan-08 0:56
sitebuilderLuc Pattyn15-Jan-08 0:56 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus315-Jan-08 23:20
invictus315-Jan-08 23:20 
Ok here it goes:
- I can not tell more about the application at this point. At this point it is only at the planning stage where we test the possibility. Getting this algorithm right is a prerequisite for any further work.

- For sake of simplicity lets assume that we want to count for all 2-bit (00, 01, 10, 11)(and as a variant perhaps also 3-bit (000, 001, etc...)) combination. It is fixed sized pattern we want to search for, but the string we are searching in is variable sized.

- Whether it is MSB or LSB is irrelevant how I see it. It is all C# strings on a intel laptop, and that is pretty much what I know about that.

- I do not need location: only the count of each pattern

- The pattern you described would be counted 3 times. It will overlap locations already counted.

To be honest I don't want a complete code, but only pointers on how to approach the bit pattern count problem on my own. So far I got 2 possible solutions:
- convert each char into a binary string of 8 bytes where each letter is either 0 or 1 and then to regular string comparison
- use unsafe code and the & operator

Neither seems to be that efficient.

In Java I already solved this problem in a kind of inefficient way: first converting to bytes, then into a binary-string (e.g. each character from the original string takes up 8 chars with either 0/1 in the binary string) and then just do a normal string comparison (e.g. str.equals("01"). However, this is 1) inefficient and 2) in Java when C# is the targeted language. Unfortunately I suck at C# at this point but are reading up on it as we speak.
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn16-Jan-08 8:56
sitebuilderLuc Pattyn16-Jan-08 8:56 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus319-Jan-08 8:41
invictus319-Jan-08 8:41 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn19-Jan-08 9:13
sitebuilderLuc Pattyn19-Jan-08 9:13 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus319-Jan-08 11:16
invictus319-Jan-08 11:16 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn19-Jan-08 11:36
sitebuilderLuc Pattyn19-Jan-08 11:36 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus319-Jan-08 12:57
invictus319-Jan-08 12:57 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn19-Jan-08 14:01
sitebuilderLuc Pattyn19-Jan-08 14:01 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus321-Jan-08 0:09
invictus321-Jan-08 0:09 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn21-Jan-08 0:45
sitebuilderLuc Pattyn21-Jan-08 0:45 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus321-Jan-08 0:57
invictus321-Jan-08 0:57 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn21-Jan-08 1:09
sitebuilderLuc Pattyn21-Jan-08 1:09 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus321-Jan-08 22:41
invictus321-Jan-08 22:41 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn22-Jan-08 1:07
sitebuilderLuc Pattyn22-Jan-08 1:07 
GeneralRe: Count bitpattern occurences in textstrings Pin
Ennis Ray Lynch, Jr.15-Jan-08 11:00
Ennis Ray Lynch, Jr.15-Jan-08 11:00 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus315-Jan-08 23:10
invictus315-Jan-08 23:10 
GeneralRe: Count bitpattern occurences in textstrings Pin
Ennis Ray Lynch, Jr.16-Jan-08 4:11
Ennis Ray Lynch, Jr.16-Jan-08 4:11 
GeneralRe: Count bitpattern occurences in textstrings Pin
PIEBALDconsult15-Jan-08 15:41
mvePIEBALDconsult15-Jan-08 15:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.