asp.net open pdf in new window code behind : Change pdf page size control SDK platform web page wpf azure web browser ITU-TR-2006-7612-part684

Chapter7
Dictionaryimplementations
Asshowningure7.1therearetwodictionaryimplementations,namelyHashDic-
tionary<K,V>andTreeDictionary<K,V>.Theformerusesakeyequalitycomparer
tocomparedictionarykeys,andthelatterusesakeycomparer,orordering,tocom-
paredictionarykeys.ThelatterimplementstheISortedDictionary<K,V>interface;
bothimplementtheIDictionary<K,V>interface.
IDictionary<K,V>
TreeDictionary<K,V>
HashDictionary<K,V>
ISortedDictionary<K,V>
ICollectionValue<KeyValuePair<K,V>>
SCG.IEnumerable<KeyValuePair<K,V>>
Figure7.1:Thedictionaryclassesandinterfaces.Solidlinesindicateasubinterface
orsubclassrelation,anddashedlinesindicateanimplementationrelation.
7.1 Hash-baseddictionaries
ClassHashDictionary<K,V>implementsinterfaceIDictionary<K,V>andrepresents
adictionaryof(key,value)pairs,orentries,usingahashtablewithlinearchaining.
EntryaccessandentrydeletionbykeytakesexpectedtimeO(1),andentryinsertion
119
Change pdf page size - Compress reduce PDF size in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
C# Code & .NET API to Compress & Decompress PDF Document
optimize scanned pdf; best pdf compressor
Change pdf page size - VB.NET PDF File Compress Library: Compress reduce PDF size in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET PDF Document Compression and Decompression Control SDK
pdf compression; change page size pdf
120 Tree-baseddictionaries
§7.2
takesexpectedtimeO(1)also.Enumerationofthekeys,valuesorentriesofahash
dictionarydoesnotguaranteeanyparticularenumerationorder,butkeyenumer-
ationorderandvalueenumeration orderfollowthe(key,value)pair enumeration
order.
ClassHashDictionary<K,V>hasthreeconstructors:
HashDictionary<K,V>()
createsanewhashdictionarywithadefaultinitialta-
blesize(16),adefaultllthreshold(0.66),andadefaultkeyequalitycomparer
forkeytypeK,seesection2.3.
HashDictionary<K,V>(SCG.IEqualityComparer<K> eqc)
createsanewhashdic-
tionary with a default initial tablesize(16), a default ll threshold d (0.66),
andthegivenkeyequalitycomparer.ThrowsNullReferenceExceptionif
eqc
is
null
.
HashDictionary<K,V>(int capacity, double fill, SCG.IEqualityComparer<K>
eqc)
createsanewhashdictionarywiththegiveninitialtablesize,thegiven
llthreshold(0.66),andthegivenkeyequalitycomparer. ThrowsNullRefer-
enceExceptionif
eqc
is
null
.
InadditiontothemethodsdescribedbyinterfaceIDictionary<K,V>,classHashDic-
tionary<K,V>hasonemethod:
ISortedDictionary<int,int>
BucketCostDistribution
()
returnsanewta-
ble
bcd
reportingthecurrentbucketcostdistributionintheinternalrepresen-
tationofthehashdictionary.Thevalueof
bcd[c]
isthenumberofbucketsthat
havecost
c
. The
bcd
tablecanbeusedtodeterminewhetheraperformance
problemmaybeduetoabadchoiceofhashfunction.Forfurtherinformation,
seethedescriptionofmethod
BucketCostDistribution
insection6.10.
7.2 Tree-baseddictionaries
ClassTreeDictionary<K,V>implementsinterfaceISortedDictionary<K,V>andrep-
resentsadictionaryof(key,value)pairs,orentries,usinganorderedbalancedred-
blackbinarytree.Entryaccess,entrydeletion,andentryinsertiontaketimeO(logn).
Enumerationofthekeys,valuesorentriesofatreedictionaryfollowthekeyorder,
asdeterminedbythekeycomparer
ClassTreeDictionary<K,V>hastwoconstructors:
TreeDictionary<K,V>()
createsanewtreedictionarywithadefaultkeycom-
parerforkeytypeK;seesection2.6.Thedefaultkeycomparerusesthenatu-
ralcomparerforK;ifKdoesnotimplementIComparable<K>orIComparable,
thenNotComparableExceptionisthrown.
TreeDictionary<K,V>(SCG.IComparer<K> cmp)
createsanewtreedictionarywith
thegivenkeycomparer.ThrowsNullReferenceExceptionif
cmp
is
null
.
C# PDF File Split Library: Split, seperate PDF into multiple files
Divide PDF file into multiple files by outputting PDF file size. control, C# developers can easily and accurately disassemble multi-page PDF document into two
pdf page size dimensions; adjusting page size in pdf
VB.NET PDF File Split Library: Split, seperate PDF into multiple
Separate source PDF document file by defined page range in VB.NET class application. Divide PDF file into multiple files by outputting PDF file size.
change font size in fillable pdf form; pdf reduce file size
§7.2
Tree-baseddictionaries 121
TreeDictionary<K,V>(SCG.IComparer<K> cmp, SCG.IEqualityComparer<K> eqc)
createsanewtreedictionarywiththegivenkeycomparerandthegivenkey
equalitycomparer.ThrowsNullReferenceExceptionif
cmp
or
eqc
is
null
.
Thekeycomparer isusedtodetermineitem equality and itemorderinthetree
dictionary. Thekeyequalitycomparerisusedonlytodeneanequalitycomparer
fortheentiredictionary.Thisisneededifthetreedictionaryisusedasanitemina
hash-basedcollection.
C# PDF Thumbnail Create SDK: Draw thumbnail images for PDF in C#.
public override Bitmap ConvertToImage(Size targetSize). Description: Convert the PDF page to bitmap with specified size. Parameters:
change paper size in pdf document; change font size pdf document
C# PDF Convert to Jpeg SDK: Convert PDF to JPEG images in C#.net
Using this C#.NET PDF to JPEG conversion library component toolkit, C# developers can easily and quickly convert a large-size multi-page PDF document to a
pdf compression settings; pdf paper size
122 Tree-baseddictionaries
§7.2
C# PDF insert text Library: insert text into PDF content in C#.net
formatted text and plain text to PDF page using .NET NET PDF edit control allows modify existing scanned PDF text. Ability to change text font, color, size and
pdf edit text size; pdf page size may not be reduced
VB.NET PDF Thumbnail Create SDK: Draw thumbnail images for PDF in
Remove Password from PDF; Change PDF Permission Settings. String = Program.RootPath + "\\" 1.pdf" Dim doc New PDFDocument(inputFilePath) Dim page As PDFPage
change font size in pdf; best way to compress pdf
Chapter8
Advancedfunctionality
8.1 Listviews
Alistviewrepresentsacontiguoussegmentofanunderlyinglistandmaybeused
toperformlocaloperationsonthatlist.Theremaybeseveral,possiblyoverlapping,
viewsonthesamelist. AlllistoperationsfrominterfaceIList<T>(section1.4.11)
applytoviewsaswell,andthetermlistisusuallytakentomeanlistorview,
whereasaAproperlistisalistthatisnotaview. Aviewhasauniqueunderlying
listthatisaproperlist.
Usinglist views,manyoperations canbeconciselyexpressedinawaythatis
efcientbothonarraylistsandlinkedlists,asshownbythepatternsinchapter9.
Anylistoperation(enumeration,itemsearch,indexing,insertion,removal,sorting,
reversal,...)canbeappliedalsotoalistview,thusrestrictingtheoperationstoa
contiguoussubsequenceofthelist. Thisimprovesorthogonalityandpredictability
andreducesthenumberofoverloadedmethodvariantsneededinthelibrary.
8.1.1 Basicconceptsoflistviews
Aviewis delimitedbya leftendpointandarightendpoint, bothofwhich areat
inter-itemspaceintheunderlyinglist.Figure8.1showsalistwithfouritems(a,b,
c,d)andsevenviews(AG).
Theoffsetofaviewisthenumberofitemsbeforeitsleftendpointintheunder-
lyinglist.Property
Offset
reportstheoffsetofaview.Intheexample,viewsAand
Ghaveoffset0,viewFhasoffset1,viewsBandChaveoffset2,viewDhasoffset
3,andviewEhasoffset4.
Thelengthofaviewisthenumberofitemsbetweentheleftandrightendpoints.
Property
Count
reports thelength ofa view. . Fora a zero-itemview, , alsocalledan
emptyview,bothendpointsareinthesameinter-itemspace.Intheexample,views
AandFhavelength2,viewsBandEhavelength0,viewsCandDhavelength1,
andviewGhaslength4.
123
C# PDF Convert to Tiff SDK: Convert PDF to tiff images in C#.net
zoomValue, The magnification of the original PDF page size. 0.1f
adjust pdf size; pdf page size
C# PDF Convert to Word SDK: Convert PDF to Word library in C#.net
zoomValue, The magnification of the original PDF page size. 0.1f
advanced pdf compressor; pdf change font size in textbox
124 Listviews
§8.1
a
0
b
1
2
3
c
d
A
B
C
D
F
G
E
Figure8.1:Sevenviewsofthesameunderlyingfour-itemlist.
Twoviews
u
and
w
ofthesameunderlyinglistoverlapiftheyhaveoneormore
itemsincommonorifoneisazero-itemviewstrictlyinsidetheother.Equivalently,
theleftendpoint ofoneisstrictlybeforetheright endpoint oftheother,andvice
versa. Formally,
u
and
w
overlapif
u.Offset < < w.Offset+w.Count
and
w.Offset <
u.Offset+u.Count
.Itfollowsthattheoverlapsrelationissymmetric,anynon-empty
view overlapswithitself,andanempty(zero-item)viewoverlapsonlywithviews
oflengthtwoormore.Intheexample,viewsA,BandCoverlapwithFandGbut
notwitheachother;viewDoverlapswithG;andviewsFandGoverlap.Eachnon-
emptyviewA,C,D,FandGoverlapswithitself,buttheemptyviewBoverlapsonly
withthestrictlyenclosingviewsFandG,andEdoesnotoverlapwithanyview.The
lengthofanoverlapisthenumberofitemsthetwoviewshaveincommon;thismay
bezerobutonlyifoneviewisemptyandstrictlyinsidetheother.
A view
u
containsa view
w
ofthesameunderlying list if
w
isnon-emptyand
theleftandrightendpointsof
w
areinside
u
,orif
w
isemptyanditsendpointsare
strictlyinside
u
. Formally,if
w.Count > > 0
itmustholdthat
u.Offset <= w.Offset
and
w.Offset+w.Count <= u.Offset+u.Count
, or if
w.Count = = 0
it must t hold that
u.Offset < < w.Offset t < < u.Offset+u.Count
. It t follows thata non-emptyview con-
tainsitself,thatanemptyviewcontainsnoviews,thatiftwoviewscontaineach
other then they have thesameoffset t and length, and that t a view contains any
emptyviewsstrictlyinsideitbutnottheemptyviewsatitsends. Inparticular,a
properlistcontainsallitsviewsexcepttheemptyviewsatitsends. Also,if
u
con-
tains
w
thentheyoverlap. Infact,
u
contains
w
ifandonlyiftheyoverlapandthe
lengthoftheoverlapequalsthelengthof
w
. Intheexample,eachoftheviewsA,
CandDcontainsitselfonly;viewFcontainsB,CandF;andviewGcontainsthe
viewsA,B,C,D,FandGbutnotE.
Section9.4presentsC#methodscorrespondingtotheabovedenitions.
§8.1
Listviews 125
8.1.2 Operationsonlistviews
Operationsonviewsinclude:
 Updates,insertionsordeletionsofitemswithinaview. . Theseoperationsim-
mediatelyaffecttheunderlyinglistandpossiblyotherviews,accordingtothe
rulesinsection8.1.5.
 Allotherlistpropertiesandmethodsmaybeusedonaviewandwilloperateon
theitemswithintheviewonly. Inparticular,onemayperformenumeration
(and backwards s enumeration), search, reversal, sorting, shufing, clearing,
andsoon.Againtheseoperationsworkontheunderlyinglistandaffectthat
listandpossiblyotherviewsofthelist.
 TheCountpropertyisthelengthoftheview,thatis,thenumberofitemsit
contains.
 TheOffsetpropertyofaviewgivestheindexoftheview’sbeginningwithin
theunderlyinglist.
 TheSlide
(i)
methodslidestheviewleft(if
i<0
)orright(if
i>0
)bythegiven
numberofitems.ThrowsArgumentOutOfRangeExceptionifthiswouldmove
eitherendpointoftheviewoutsidetheunderlyinglist,thatis,if
i+Offset < < 0
or
i+Offset+Count > > Underlying.Count
.
 TheSlide
(i,n)
methodslidestheviewby
i
itemsandalsosetsitssizeto
n
,
thusextendingtheviewtoincludemoreitemsorshrinkingittoincludefewer.
ThrowsArgumentOutOfRangeExceptionifthiswouldmoveeitherendpointof
theviewoutsidetheunderlyinglist,thatis,if
i+Offset < 0
or
i+Offset+n >
Underlying.Count
.
IList<T>
Span
(IList<T> w)
returnsanewviewspannedbytwoexistingviews,
ifany. Thecall
u.Span(w)
producesanewviewwhoseleftendpointistheleft
endpointof
u
andwhoserightendpointistherightendpointof
w
. Iftheright
endpoint of
w
is strictly totheleftoftheleftendpoint of
u
,then
null
isre-
turned.Theviews
u
and
w
musthavethesameunderlyinglist,oroneorboth
maybethatunderlyinglist,and
w
mustbenon-
null
;otherwiseIncompatible-
ViewExceptionisthrown.
When
list
istheunderlyinglistofview
u
,then
u.Span(list)
isaviewthat
spansfromtheleftendpointof
u
totheendofthelist,and
list.Span(u)
isa
viewthatspansfromthebeginningofthelisttotherightendpointof
u
.
bool
TrySlide
(i)
returnstrueifthegivenviewcanbeslidby
i
items,and
in that case slides it exactlyas
Slide(i)
; otherwisereturns falseanddoes
notmodifythegivenview. Moreprecisely,returnstrueif
i+Offset >= = 0
and
i+Offset+Count <= Underlying.Count
. ThrowsReadOnlyCollectionException
iftheviewisread-only.
126 Listviews
§8.1
bool
TrySlide
(i, n)
returns trueifthegivenview can beslid d by
i
items
andhaveitslengthsetto
n
,andinthatcaseslidesitexactlyas
Slide(i, n)
;
otherwisereturnsfalseanddoesnotmodifythegivenview. Moreprecisely,
returnstrueif
i+Offset >= 0
and
i+Offset+n <= Underlying.Count
. Throws
ReadOnlyCollectionExceptioniftheviewisread-only.
 ThepropertyUnderlyingreturnstheview’sunderlyinglist,orreturns
null
ifappliedtoaproperlist. Theexpression
(list.Underlying != = null)
istrue
when
list
isaviewandfalsewhenitisaproperlist. Similarly,theexpres-
sion
(list.Underlying ?? list)
evaluatestotheunderlyinglistregardlessof
whether
list
isavieworitselfaproperlist.
8.1.3 Creatinglistviews
Thereareseveralwaystocreateaviewfromalistorview
list
:
 Method
list.
View
(i,n)
creates and d returns s a new view with offset
i
and
length
n
. ThrowsArgumentOutOfRangeExceptioniftheviewwouldnot t t
inside
list
;ormoreprecisely,if
i < < 0
or
n < < 0
or
i+n > > list.Count
.
 Method
list.
ViewOf
(x)
createsandreturnsanewviewoflength1containing
therstoccurrenceofitem
x
in
list
,ifany;otherwisereturns
null
.
 Method
list.
LastViewOf
(x)
createsandreturnsanewviewoflength1con-
tainingthelastoccurrenceofitem
x
in
list
,ifany;otherwisereturns
null
.
Thesemethodsworkwhether
list
isavieworaproperlist. Theyalwaysproduce
aviewoftheunderlyinglist,sothe
Offset
oftheresultingviewwillberelativeto
thatunderlyinglist,nottoanyview.
8.1.4 One-itemviewsandzero-itemviews
One-itemandzero-itemviewsaresurprisinglyusefulasdifferentkindsofcursors
onalist:
 Ann-itemlist
list
hasndistinctone-itemviews,createdby
list.View(i,1)
where0i<list:Count.Aone-itemviewpointsataparticularitem.
 Ann-itemlist
list
hasn+1distinctzero-itemviews,createdby
list.View(i,0)
where0ilist:Count.Azero-itemview
u
has
u.Count = = 0
andrepresents
apositionbetween,orbeforeorafter,listitems.
Zero-itemview areconceptually andpractically useful as inter-itemcursors, pre-
ciselybecausethereareenoughofthemtounambiguouslypointatapre-item,inter-
item,orpost-itemspace.
§8.1
Listviews 127
8.1.5 Theeffectofinsertingordeletinganitem
The effect t on a a view w ofan operation, , such as insertion n or r deletion, , depends s on
whether theoperation isperformedon anotherview ortheunderlying list, or is
performedexplicitlyonthatview.Insertionsanddeletionstotheunderlyinglistor
toanotherviewbeforeorinsideagivenviewimmediatelyshowthroughtheview.
Thefollowingrulesapplywhentheoperationisperformedonanothervieworon
theunderlyinglist:
 Aninsertionattheunderlyinglist’sposition
i
increasesby1theoffsetofview
u
if
i <= = u.Offset
.
 Aninsertionattheunderlyinglist’sposition
i
increasesby1thelengthofview
u
if
u.Offset < < i i < < u.Offset+Count
. Itfollowsthatthelengthofazero-item
orone-itemviewisneveraffectedbyinsertionsintoanothervieworintothe
underlyinglist.Thiscontributestotheirusefulnessascursors.
 Adeletionattheunderlyinglist’sposition
i
decreasesby1theoffsetofview
u
if
i < < u.Offset
.
 Adeletionattheunderlyinglist’sposition
i
decreasesby1thelengthofview
u
if
u.Offset <= i i < u.Offset+Count
. It t follows that deletion fromanother
vieworfromtheunderlyinglistneveraffectsthelengthofazero-itemview,
whereasitmightremovethesoleiteminaone-itemview.
Operationsperformedexplicitlyonagivenview
w
followtheserules:
 Insertionexplicitlyperformedonaviewincreasesitslengthby1andleaves
itsoffsetunaffected.
 Adeletionexplicitlyperformedonaviewdecreasesitslengthby1andleaves
itsoffsetunaffected.
Forinstance,aninsertionatthebeginning oftheunderlying listin gure8.1 is
at position
i=0
; it t increases theoffsetofall views AG by 1 but does not affect
theirlength.However,aninsertionexplicitlyperformedatthebeginningofviewA
increasesthelengthofAby1andleavesitsoffsetunaffectedat0,andincreasesthe
offsetofallviewsBGby1butdoesnotaffecttheirlength.
Aninsertionattheendoftheunderlyinglistingure8.1isatposition
i=4
;its
onlyeffect ontheviewsAGistoincreasetheoffset ofthezero-itemview E. . In
particular,itdoesnotaffectthewhole-listviewG.However,aninsertionintoview
EwillincreasethelengthofEbutnotaffectitsoffset,norwillitaffectanyofthe
viewsA,B,C,D,F,G.
Anewlycreatedviewisvalid,butsomeoperationsonalistoranotherviewof
thelistmayinvalidatetheview;seesection8.1.6. Alloperationsoninvalidviews,
exceptfor
IsValid
and
Dispose
,willthrowViewDisposedException.
128 Listviews
§8.1
8.1.6 Listviewsandmulti-itemlistoperations
Operationssuchas
Reverse
,
Sort
and
Shuffle
onalistoralistview
u
potentially
affectmanyitemsandthereforemanyviewsatonce.
u.Clear()
where
u
is a list or list view affects another view
w
of thesame
underlyinglistasfollows:
 If
w
contains
u
,then
w.Count
isreducedby
u.Count
.
 Otherwise,if
u
contains
w
(butnotviceversa),then
w
iscleared:
w.Count
becomeszero,and
w.Offset
becomes
u.Offset
.
 Otherwise,if
w
iscompletelytotheleftof
u
,then
w
isunchanged.
 Otherwise,if
w
iscompletelytotherightof
u
,then
w.Offset
isreducedby
u.Count
.
 Otherwise,if
u
and
w
overlap(butneithercontainstheother)and
w.Offset
< u.Offset
,then
w.Count
isreducedbythelengthoftheoverlap.
 Otherwise,if
u
and
w
overlap(butneithercontainstheother)and
w.Offset
> u.Offset
,then
w.Offset
isreducedto
u.Offset
and
w.Count
isreduced
bythelengthoftheoverlap.
Thesecasesareexhaustive.Forinstance,if
w.Offset = = u.Offset
,theneither
w
isanemptyviewtotheleftof
u
,or
w
contains
u
,or
u
contains
w
.Theintention
isthat
u.Clear()
affects
u
andotherviewsinthesamewayasremovingthe
itemsof
u
onebyone,exceptthatthetwoprocedureswillraisedifferentevents.
Inparticular,if
u
isazero-itemview,then
u.Clear()
affectsnootherview,and
if
u
isaone-itemview,then
u.Clear()
hasthesameeffectsasdeletingtheitem
atposition
u.Offset
by
u.Remove()
.
u.Reverse()
,where
u
isalistorview,affectsanotherview
w
ofthesameun-
derlyinglistasfollows:
 If
w
contains
u
,thentheoffsetandlengthof
w
areunchanged.
 Otherwise,if
u
contains
w
(butnotviceversa),then
w
ismirroredinside
u
bysetting
w.Offset
to
2 * * u.Offset + + u.Count t - - v.Offset t - - v.Count
.
 Otherwise,if
u
and
w
donotoverlap,then
w
isunchanged.
Inparticular,anyzero-itemviewsattheendsof
u
areunchanged.
 Otherwise,if
u
and
w
overlap(butnoneiscontainedintheother),then
w
isinvalidated.
Itfollowsthat
u.Reverse()
doesnotinvalidateanyzero-itemorone-item
views.Also,when
u
isaproperlist,then
u.Reverse()
doesnotinvalidate
anyviewsatall.
Thesecasesareexhaustive.Also,when
u
isazero-itemorone-itemview,then
u.Reverse()
affectsnootherview.
Documents you may be interested
Documents you may be interested