<s>
In	O
computing	O
,	O
a	O
piece	B-Data_Structure
table	I-Data_Structure
is	O
a	O
data	B-General_Concept
structure	I-General_Concept
typically	O
used	O
to	O
represent	O
a	O
text	B-General_Concept
document	I-General_Concept
while	O
it	O
is	O
edited	O
in	O
a	O
text	B-Application
editor	I-Application
.	O
</s>
<s>
Subsequent	O
inserts	O
and	O
deletes	O
replace	O
a	O
span	O
by	O
combinations	O
of	O
one	O
,	O
two	O
,	O
or	O
three	O
references	O
to	O
sections	O
of	O
either	O
the	O
original	O
document	O
or	O
to	O
a	O
buffer	B-General_Concept
holding	O
inserted	O
text	O
.	O
</s>
<s>
Typically	O
the	O
text	O
of	O
the	O
original	O
document	O
is	O
held	O
in	O
one	O
immutable	B-Application
block	O
,	O
and	O
the	O
text	O
of	O
each	O
subsequent	O
insert	O
is	O
stored	O
in	O
new	O
immutable	B-Application
blocks	O
.	O
</s>
<s>
Because	O
even	O
deleted	O
text	O
is	O
still	O
included	O
in	O
the	O
piece	B-Data_Structure
table	I-Data_Structure
,	O
this	O
makes	O
multi-level	O
or	O
unlimited	O
undo	B-Application
easier	O
to	O
implement	O
with	O
a	O
piece	B-Data_Structure
table	I-Data_Structure
than	O
with	O
alternative	O
data	B-General_Concept
structures	I-General_Concept
such	O
as	O
a	O
gap	B-Data_Structure
buffer	I-Data_Structure
.	O
</s>
<s>
This	O
data	B-General_Concept
structure	I-General_Concept
was	O
invented	O
by	O
J	O
Strother	O
Moore	O
.	O
</s>
<s>
For	O
this	O
description	O
,	O
we	O
use	O
buffer	B-General_Concept
as	O
the	O
immutable	B-Application
block	O
to	O
hold	O
the	O
contents	O
.	O
</s>
<s>
A	O
piece	B-Data_Structure
table	I-Data_Structure
consists	O
of	O
three	O
columns	O
:	O
</s>
<s>
In	O
addition	O
to	O
the	O
table	O
,	O
two	O
buffers	B-General_Concept
are	O
used	O
to	O
handle	O
edits	O
:	O
</s>
<s>
"	O
Original	O
buffer	B-General_Concept
"	O
:	O
A	O
buffer	B-General_Concept
to	O
the	O
original	O
text	B-General_Concept
document	I-General_Concept
.	O
</s>
<s>
This	O
buffer	B-General_Concept
is	O
read-only	O
.	O
</s>
<s>
"	O
Add	O
buffer	B-General_Concept
"	O
:	O
A	O
buffer	B-General_Concept
to	O
a	O
temporary	O
file	O
.	O
</s>
<s>
This	O
buffer	B-General_Concept
is	O
append-only	O
.	O
</s>
<s>
Definition	O
:	O
Index(i )	O
:	O
return	O
the	O
character	O
at	O
position	O
iTo	O
retrieve	O
the	O
i-th	O
character	O
,	O
the	O
appropriate	O
entry	O
in	O
a	O
piece	B-Data_Structure
table	I-Data_Structure
is	O
read	O
.	O
</s>
<s>
Given	O
the	O
following	O
buffers	B-General_Concept
and	O
piece	B-Data_Structure
table	I-Data_Structure
:	O
</s>
<s>
To	O
access	O
the	O
i-th	O
character	O
,	O
the	O
appropriate	O
entry	O
in	O
the	O
piece	B-Data_Structure
table	I-Data_Structure
is	O
looked	O
up	O
.	O
</s>
<s>
For	O
instance	O
,	O
to	O
get	O
the	O
value	O
of	O
Index(15 )	O
,	O
the	O
3rd	O
entry	O
of	O
piece	B-Data_Structure
table	I-Data_Structure
is	O
retrieved	O
.	O
</s>
<s>
The	O
piece	B-Data_Structure
table	I-Data_Structure
entry	O
instructs	O
the	O
program	O
to	O
look	O
for	O
the	O
characters	O
in	O
the	O
"	O
add	O
file	O
"	O
buffer	B-General_Concept
,	O
starting	O
at	O
index	O
18	O
in	O
that	O
buffer	B-General_Concept
.	O
</s>
<s>
The	O
relative	O
index	O
in	O
that	O
entry	O
is	O
15-12	O
=	O
3	O
,	O
which	O
is	O
added	O
to	O
the	O
start	O
position	O
of	O
the	O
entry	O
in	O
the	O
buffer	B-General_Concept
to	O
obtain	O
index	O
of	O
the	O
letter	O
:	O
3+18	O
=	O
21	O
.	O
</s>
<s>
The	O
value	O
of	O
Index(15 )	O
is	O
the	O
21st	O
character	O
of	O
the	O
"	O
add	O
file	O
"	O
buffer	B-General_Concept
,	O
which	O
is	O
the	O
character	O
"	O
o	O
"	O
.	O
</s>
<s>
For	O
the	O
buffers	B-General_Concept
and	O
piece	B-Data_Structure
table	I-Data_Structure
given	O
above	O
,	O
the	O
following	O
text	O
is	O
shown	O
:	O
</s>
<s>
The	O
deletion	O
is	O
at	O
the	O
start	O
or	O
end	O
of	O
a	O
piece	O
entry	O
,	O
in	O
which	O
case	O
the	O
appropriate	O
entry	O
in	O
piece	B-Data_Structure
table	I-Data_Structure
is	O
modified	O
.	O
</s>
<s>
Several	O
text	B-Application
editors	I-Application
use	O
an	O
in-RAM	O
piece	B-Data_Structure
table	I-Data_Structure
internally	O
,	O
including	O
Bravo	B-Application
,	O
Abiword	B-Language
,	O
Atom	B-Application
and	O
Visual	B-Language
Studio	I-Language
Code	I-Language
.	O
</s>
<s>
The	O
"	O
fast	O
save	O
"	O
feature	O
in	O
some	O
versions	O
of	O
Microsoft	O
Word	O
uses	O
a	O
piece	B-Data_Structure
table	I-Data_Structure
for	O
the	O
on-disk	O
file	O
format	O
.	O
</s>
<s>
The	O
on-disk	O
representation	O
of	O
text	B-General_Concept
files	I-General_Concept
in	O
the	O
Oberon	B-Application
System	I-Application
uses	O
a	O
piece	B-Data_Structure
chain	I-Data_Structure
technique	O
that	O
allows	O
pieces	O
of	O
one	O
document	O
to	O
point	O
to	O
text	O
stored	O
in	O
some	O
other	O
document	O
,	O
similar	O
to	O
transclusion	O
.	O
</s>
