Liking cljdoc? Tell your friends :D

kmp-search.core

functions to search a byte stream for a byte pattern

  • create a context with the byte pattern

  • call the search function repeatedly to process each sequential buffer of stream contents

  • each call to search returns a new context when it:

    • finds a match within a buffer, or
    • exhausts a buffer without finding a match
  • retrieve the search result from the new context using the match function. The result is either:

    • if a match was found, a Long containing the offset of the match within the stream of bytes processed, or

    • if no match was not found, nil

  • each returned context also contains enough state to allow matching across buffer boundaries

  • to find all matches, call search on each buffer repeatedly until match returns nil, then continue searching the next buffer

    • the context for each call to search will be the context returned by the previous call
  • search-file is useful both in its own right and as an example

reference: http://www.inf.fh-flensburg.de/lang/algorithmen/pattern/kmpen.htm

functions to search a byte stream for a byte pattern

- create a context with the byte pattern

- call the search function repeatedly to process each sequential
  buffer of stream contents

- each call to search returns a new context when it:
  - finds a match within a buffer, or
  - exhausts a buffer without finding a match

- retrieve the search result from the new context using the
  match function. The result is either:

    - if a match was found, a Long containing the offset of the
      match within the stream of bytes processed, or

    - if no match was not found, nil

- each returned context also contains enough state to allow matching
  across buffer boundaries

- to find all matches, call search on each buffer repeatedly until
  match returns nil, then continue searching the next buffer

  - the context for each call to search will be the context returned
    by the previous call

- search-file is useful both in its own right and as an example

reference: http://www.inf.fh-flensburg.de/lang/algorithmen/pattern/kmpen.htm
raw docstring

contextclj

(context pattern)

matchclj

(match this)

searchclj

(search this buffer)
(search this buffer limit)

search-fileclj

(search-file pattern file & {:keys [buffer-size] :or {buffer-size 1024}})

returns a vector containing all the offsets where a byte pattern appears within a file

returns a vector containing all the offsets where a byte pattern
appears within a file
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close