<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
the	O
augmented	B-Application
map	I-Application
is	O
an	O
abstract	O
data	O
type	O
(	O
ADT	O
)	O
based	O
on	O
ordered	O
maps	O
,	O
which	O
associates	O
each	O
ordered	O
map	B-Application
an	O
augmented	O
value	O
.	O
</s>
<s>
For	O
an	O
ordered	O
map	B-Application
with	O
key	O
type	O
,	O
comparison	O
function	O
on	O
and	O
value	O
type	O
,	O
the	O
augmented	O
value	O
is	O
defined	O
based	O
on	O
two	O
functions	O
:	O
a	O
base	O
function	O
and	O
a	O
combine	O
function	O
,	O
where	O
is	O
the	O
type	O
of	O
the	O
augmented	O
value	O
.	O
</s>
<s>
Then	O
the	O
augmented	O
value	O
of	O
an	O
ordered	O
map	B-Application
is	O
defined	O
as	O
follows	O
:	O
</s>
<s>
Accordingly	O
,	O
an	O
augmented	B-Application
map	I-Application
can	O
be	O
formally	O
defined	O
as	O
a	O
seven-tuple	O
.	O
</s>
<s>
For	O
example	O
,	O
an	O
augmented	B-Application
map	I-Application
with	O
integral	O
keys	O
and	O
values	O
,	O
on	O
which	O
the	O
augmented	O
value	O
is	O
defined	O
as	O
the	O
sum	O
of	O
all	O
values	O
in	O
the	O
map	B-Application
,	O
is	O
defined	O
as	O
:	O
</s>
<s>
As	O
an	O
abstract	O
data	O
type	O
,	O
the	O
augmented	B-Application
map	I-Application
is	O
often	O
used	O
to	O
model	O
problems	O
and	O
serves	O
as	O
an	O
abstraction	O
with	O
a	O
useful	O
interface	O
.	O
</s>
<s>
In	O
addition	O
to	O
the	O
interface	O
for	O
a	O
standard	O
ordered	O
map	B-Application
,	O
the	O
augmented	B-Application
map	I-Application
should	O
also	O
support	O
functions	O
for	O
range	O
sums	O
.	O
</s>
<s>
Usually	O
,	O
they	O
would	O
require	O
some	O
certain	O
representation	O
of	O
augmented	B-Application
maps	I-Application
,	O
and	O
certain	O
conditions	O
for	O
input	O
parameters	O
.	O
</s>
<s>
When	O
the	O
augmented	B-Application
map	I-Application
is	O
implemented	O
using	O
augmented	O
trees	O
,	O
this	O
function	O
can	O
be	O
implemented	O
asymptotically	O
more	O
efficient	O
than	O
the	O
naive	O
implementation	O
.	O
</s>
<s>
The	O
augmented	B-Application
map	I-Application
can	O
be	O
supported	O
efficiently	O
by	O
augmented	O
trees	O
,	O
where	O
each	O
tree	O
node	O
is	O
augmented	O
by	O
the	O
augmented	O
value	O
of	O
all	O
entries	O
in	O
its	O
subtree	O
.	O
</s>
<s>
In	O
this	O
case	O
,	O
by	O
combining	O
the	O
partial	O
sums	O
in	O
the	O
tree	O
nodes	O
,	O
any	O
range	O
sum	O
can	O
be	O
returned	O
in	O
time	O
on	O
an	O
augmented	B-Application
map	I-Application
of	O
size	O
,	O
assuming	O
both	O
and	O
have	O
constant	O
cost	O
.	O
</s>
<s>
Another	O
implementation	O
is	O
to	O
use	O
prefix	O
structures	O
,	O
which	O
stores	O
the	O
augmented	O
value	O
of	O
all	O
prefixes	O
of	O
the	O
map	B-Application
.	O
</s>
<s>
For	O
the	O
above-defined	O
augmented	B-Application
map	I-Application
,	O
the	O
prefix	O
structure	O
is	O
an	O
array	O
stored	O
the	O
prefix	O
sum	O
of	O
the	O
values	O
,	O
sorted	O
by	O
their	O
keys	O
.	O
</s>
<s>
Prefix	O
structures	O
are	O
particularly	O
useful	O
for	O
aug_left	O
,	O
but	O
can	O
be	O
inefficient	O
to	O
implement	O
other	O
functions	O
on	O
the	O
augmented	B-Application
map	I-Application
interface	O
.	O
</s>
<s>
An	O
augmented	B-Application
map	I-Application
can	O
be	O
defined	O
for	O
this	O
problem	O
,	O
where	O
the	O
keys	O
are	O
the	O
left	O
endpoints	O
of	O
all	O
intervals	O
,	O
values	O
are	O
the	O
corresponding	O
right	O
endpoints	O
,	O
and	O
the	O
augmented	O
value	O
is	O
the	O
maximum	O
value	O
of	O
all	O
right	O
endpoints	O
in	O
the	O
map	B-Application
.	O
</s>
<s>
When	O
implemented	O
with	O
augmented	O
trees	O
,	O
the	O
augmented	B-Application
map	I-Application
is	O
exactly	O
an	O
interval	B-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
An	O
augmented	B-Application
map	I-Application
can	O
be	O
defined	O
for	O
this	O
problem	O
,	O
which	O
is	O
a	O
two-level	O
nested	O
map	B-Application
structure	O
.	O
</s>
<s>
The	O
outer	O
map	B-Application
stores	O
all	O
points	O
and	O
sort	O
them	O
by	O
their	O
x-coordinates	O
.	O
</s>
<s>
The	O
augmented	O
value	O
of	O
the	O
outer	O
map	B-Application
is	O
an	O
inner	O
augmented	B-Application
map	I-Application
structure	O
,	O
which	O
stores	O
the	O
same	O
set	O
of	O
points	O
as	O
the	O
outer	O
map	B-Application
,	O
but	O
sorts	O
them	O
by	O
their	O
y-coordinates	O
.	O
</s>
<s>
The	O
augmentation	O
of	O
the	O
inner	O
trees	O
accumulate	O
the	O
count	O
of	O
points	O
,	O
i.e.	O
,	O
the	O
augmented	O
value	O
of	O
an	O
inner	O
map	B-Application
is	O
its	O
size	O
.	O
</s>
<s>
Accordingly	O
,	O
the	O
combine	O
function	O
of	O
the	O
outer	O
map	B-Application
is	O
to	O
take	O
a	O
union	O
of	O
the	O
two	O
inner	O
augmented	B-Application
maps	I-Application
.	O
</s>
<s>
To	O
answer	O
the	O
range	O
query	O
in	O
rectangle	O
,	O
the	O
query	O
algorithm	O
extracts	O
the	O
augmented	O
value	O
of	O
the	O
outer	O
map	B-Application
in	O
the	O
key	O
range	O
,	O
which	O
is	O
an	O
inner	O
map	B-Application
of	O
all	O
desired	O
points	O
sorted	O
by	O
y-coordinates	O
.	O
</s>
<s>
Therefore	O
,	O
the	O
algorithm	O
takes	O
another	O
aug_range	O
on	O
this	O
inner	O
map	B-Application
and	O
gets	O
the	O
result	O
.	O
</s>
<s>
If	O
both	O
the	O
inner	O
and	O
the	O
outer	O
maps	O
are	O
implemented	O
by	O
augmented	O
trees	O
,	O
then	O
the	O
whole	O
two-level	O
map	B-Application
structure	O
becomes	O
a	O
range	B-Data_Structure
tree	I-Data_Structure
structure	O
.	O
</s>
<s>
If	O
the	O
inner	O
map	B-Application
is	O
supported	O
by	O
the	O
augmented	O
tree	O
structure	O
,	O
and	O
the	O
outer	O
tree	O
is	O
supported	O
as	O
the	O
prefix	O
structure	O
,	O
then	O
the	O
algorithm	O
becomes	O
a	O
sweepline	B-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
Other	O
examples	O
include	O
segment	O
queries	O
,	O
inverted	B-Algorithm
index	I-Algorithm
searching	O
,	O
rectangle	O
queries	O
,	O
etc	O
.	O
</s>
<s>
A	O
parallel	O
implementation	O
of	O
the	O
augmented	B-Application
map	I-Application
interface	O
is	O
provided	O
in	O
a	O
library	O
PAM	B-Language
.	O
</s>
