相关疑难解决方法(0)

Stackoverflow与专门的Hashtbl(通过Hashtbl.make)

我正在使用这段代码并触发stackoverflow,如果我使用Extlib的Hashtbl,则不会发生错误.没有stackoverflow使用专门的Hashtbl的任何提示?

module ColorIdxHash = Hashtbl.Make(
  struct
    type t = Img_types.rgb_t
    let equal = (==)
    let hash = Hashtbl.hash
  end
)
(* .. *)
let (ctable: int ColorIdxHash.t) = ColorIdxHash.create 256 in
    for x = 0 to width -1 do
      for y = 0 to height -1 do
        let c = Img.get img x y in
        let rgb = Color.rgb_of_color c in
          if not (ColorIdxHash.mem ctable rgb) then ColorIdxHash.add ctable rgb (ColorIdxHash.length ctable)
      done
    done;
(* .. *)
Run Code Online (Sandbox Code Playgroud)

backtrace指向hashtbl.ml:

致命错误:异常Stack_overflow在文件"hashtbl.ml"处引发,第54行,字符16-40从文件"img/write_bmp.ml",第150行,字符52-108调用...

任何提示?

stack-overflow ocaml hashtable

4
推荐指数
1
解决办法
209
查看次数

标签 统计

hashtable ×1

ocaml ×1

stack-overflow ×1