Skip to content

Commit 54610e2

Browse files
committed
update readme and CCParse to remove uses of CCVector
1 parent f8174fd commit 54610e2

File tree

2 files changed

+29
-34
lines changed

2 files changed

+29
-34
lines changed

README.md

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ changes in this release.
6666

6767
2. Another large change is the removal (at last!) of functions deprecated
6868
in 2.8, related to the spread of `Seq.t` as the standard iterator type.
69-
Functions like `CCVector.of_seq` now operate on this standard `Seq.t` type,
69+
Functions like `CCVec.of_seq` now operate on this standard `Seq.t` type,
7070
and old-time iteration based on [iter](https://github.com/c-cube/iter)
7171
is now named `of_iter`, `to_iter`, etc.
7272

@@ -439,18 +439,14 @@ map =
439439
- : string option = Some "33"
440440
```
441441

442-
### New types: `CCVector`, `CCHeap`, `CCResult`, `CCSexp`, `CCByte_buffer`
442+
### New types: `CCVec`, `CCHeap`, `CCResult`, `CCSexp`, `CCByte_buffer`
443443

444444
Containers also contains (!) a few datatypes that are not from the standard
445445
library but that are useful in a lot of situations:
446446

447-
- `CCVector`:
448-
A resizable array, with a mutability parameter. A value of type
449-
`('a, CCVector.ro) CCVector.t` is an immutable vector of values of type `'a`,
450-
whereas a `('a, CCVector.rw) CCVector.t` is a mutable vector that
451-
can be modified. This way, vectors can be used in a quite functional
452-
way, using operations such as `map` or `flat_map`, or in a more
453-
imperative way.
447+
- `CCVec`:
448+
A simple and efficient dynamic array.
449+
This was called `CCVector` but the old module is deprecated now.
454450
- `CCHeap`:
455451
A priority queue (currently, leftist heaps) functorized over
456452
a module `sig val t val leq : t -> t -> bool` that provides a type `t`
@@ -474,43 +470,42 @@ library but that are useful in a lot of situations:
474470
Now for a few examples:
475471

476472
```ocaml
477-
# (* create a new empty vector. It is mutable, for otherwise it would
478-
not be very useful. *)
479-
CCVector.create;;
480-
- : unit -> ('a, CCVector.rw) CCVector.t = <fun>
481-
482-
# (* init, similar to Array.init, can be used to produce a
483-
vector that is mutable OR immutable (see the 'mut parameter?) *)
484-
CCVector.init ;;
485-
- : int -> (int -> 'a) -> ('a, 'mut) CCVector.t = <fun>
473+
# (* create a new empty vector. *)
474+
CCVec.create;;
475+
- : unit -> 'a CCVec.t = <fun>
476+
477+
# (* init, similar to Array.init, can be used to produce a new vector
478+
of given size *)
479+
CCVec.init ;;
480+
- : int -> (int -> 'a) -> 'a CCVec.t = <fun>
486481
```
487482

488483
```ocaml non-deterministic=output
489484
# (* use the infix (--) operator for creating a range. Notice
490485
that v is a vector of integer but its mutability is not
491486
decided yet. *)
492-
let v = CCVector.(1 -- 10);;
487+
let v = CCVec.(1 -- 10);;
493488
val v : (int, '_a) CCVector.t = <abstr>
494489
```
495490

496491
```ocaml
497-
# Format.printf "v = @[%a@]@." (CCVector.pp CCInt.pp) v;;
492+
# Format.printf "v = @[%a@]@." (CCVec.pp CCInt.pp) v;;
498493
v = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
499494
- : unit = ()
500-
# CCVector.push v 42;;
495+
# CCVec.push v 42;;
501496
- : unit = ()
502497
503498
# v (* now v is a mutable vector *);;
504-
- : (int, CCVector.rw) CCVector.t = <abstr>
499+
- : int CCVec.t = <abstr>
505500
506501
# (* functional combinators! *)
507-
let v2 : _ CCVector.ro_vector = v
508-
|> CCVector.map (fun x-> x+1)
509-
|> CCVector.filter (fun x-> x mod 2=0)
510-
|> CCVector.rev ;;
511-
val v2 : int CCVector.ro_vector = <abstr>
502+
let v2 : _ CCVec.t = v
503+
|> CCVec.map (fun x-> x+1)
504+
|> CCVec.filter (fun x-> x mod 2=0)
505+
|> CCVec.rev ;;
506+
val v2 : int CCVec.t = <abstr>
512507
513-
# Format.printf "v2 = @[%a@]@." (CCVector.pp CCInt.pp) v2;;
508+
# Format.printf "v2 = @[%a@]@." (CCVec.pp CCInt.pp) v2;;
514509
v2 = 10, 8, 6, 4, 2
515510
- : unit = ()
516511
```
@@ -521,7 +516,7 @@ module IntHeap = CCHeap.Make(struct type t = int let leq = (<=) end);;
521516
```
522517

523518
```ocaml
524-
# let h = v2 |> CCVector.to_iter |> IntHeap.of_iter ;;
519+
# let h = v2 |> CCVec.to_iter |> IntHeap.of_iter ;;
525520
val h : IntHeap.t = <abstr>
526521
527522
# (* We can print the content of h

src/core/CCParse.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ module Position = struct
3232
type t = position
3333

3434
let compute_line_offsets_ (s : string) : int array =
35-
let lines = CCVector.create () in
35+
let lines = CCVec.create () in
3636
let i = ref 0 in
37-
CCVector.push lines 0;
37+
CCVec.push lines 0;
3838
while !i < String.length s do
3939
match String.index_from s !i '\n' with
4040
| exception Not_found -> i := String.length s
4141
| j ->
42-
CCVector.push lines j;
42+
CCVec.push lines j;
4343
i := j + 1
4444
done;
45-
CCVector.to_array lines
45+
CCVec.to_array lines
4646

4747
let line_offsets_ cs =
4848
match cs.line_offsets with
@@ -116,7 +116,7 @@ type state = {
116116
where:
117117
[type global = {
118118
mutable memo: Memo_state.t option;
119-
line_offsets: int CCVector.vector;
119+
line_offsets: int CCVec.vector;
120120
}
121121
122122
with line_offsets used to cache the offset where each line begins,

0 commit comments

Comments
 (0)