asp.net open pdf in new window code behind : Can a pdf file be compressed control application utility azure html .net visual studio ITU-TR-2006-7611-part683

Chapter6
Collectionimplementations
Theprecedingchaptersintroducedthecollectioninterfaces,orconcepts.Thischap-
ter describes thecollectionclasses, or implementations: : data a structures and d al-
gorithms. Thecollectionclassesandtheinterfacestheyimplementareshown n in
gure6.2whichisanextensionofgure4.1.
A collection class s is partially characterized d by y its features: : does s it allow du-
plicates, areduplicates storedexplicitly,how w fastismembershiptest(
Contains
),
and so on. . Some e ofthe these properties are accessible as s C# # properties s called
AllowsDuplicates
,
DuplicatesByCounting
,
IsFixedSize
,andsoon. Anoverviewof
thecollectionclassesfromthisperspectiveisgiveningure6.1.
Collectionclass
AllowsDuplicates
DuplicatesByCounting
IsFixedSize
FIFO
default
ContainsSpeed
IndexingSpeed
CircularQueue<T>
true
false
false
ArrayList<T>
true
false
false
false
Linear
Constant
LinkedList<T>
true
false
false
true
Linear
Linear
HashedArrayList<T>
false
true
false
false
Constant
Constant
HashedLinkedList<T>
false
true
false
true
Constant
Linear
WrappedArray<T>
true
false
true
(throws)
Linear
Constant
SortedArray<T>
false
true
false
Logarithmic
Constant
TreeSet<T>
false
true
false
Logarithmic
Logarithmic
TreeBag<T>
true
true
false
Logarithmic
Logarithmic
HashSet<T>
false
true
false
Constant
HashBag<T>
true
true
false
Constant
IntervalHeap<T>
true
false
false
Figure6.1:PropertiesofC5collectionclasses.Inallcases,property
CountSpeed
has
thevalue
Constant
.
109
Can a pdf file be compressed - Compress reduce PDF size in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
C# Code & .NET API to Compress & Decompress PDF Document
change paper size in pdf document; reader shrink pdf
Can a pdf file be compressed - 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
adjust pdf size preview; change page size pdf acrobat
110 Collectionimplementations
§6.0
ISequenced<T>
ICollection<T>
IExtensible<T>
ICollectionValue<T>
SCG.IEnumerable<T>
IIndexed<T>
IPersistentSorted<T>
IPriorityQueue<T>
HashSet<T>
HashBag<T>
TreeSet<T>
TreeBag<T>
IntervalHeap<T>
SortedArray<T>
IList<T>
HashedArrayList<T>
ArrayList<T>
LinkedList<T>
HashedLinkedList<T>
CircularQueue<T>
IQueue<T>
IStack<T>
WrappedArray<T>
SC.IList
SCG.ICollection<T>
IDirectedCollectionValue<T>
IDirectedEnumerable<T>
SCG.IList<T>
IIndexedSorted<T>
ISorted<T>
ICloneable
IShowable
Figure6.2:Thecollectionclassesandinterfaces.Solidlinesindicateasubinterface
relation,anddashedlinesindicateanimplementationrelation.
VB.NET PDF Convert to Tiff SDK: Convert PDF to tiff images in vb.
When converting PDF document to TIFF image using VB.NET program, do you Originally, TIFF stands for Tagged Image File Format which can be compressed and
pdf compression settings; best pdf compressor online
VB.NET TIFF: How to Convert TIFF to PDF in a VB.NET Doc Imaging
A TIFF file can be compressed with several methods, but this If you want to restore the file with a smallest possible size, you should choose TIFF over PDF.
change font size pdf text box; adjust pdf page size
§6.2
Circularqueues 111
6.1 Circularqueues
ClassCircularQueue<T>implementstheinterfacesIQueue<T>(seesections1.4.10
and4.11)andIStack<T>(sections1.4.9and4.14)andusesanunderlyingarrayto
implementarst-in-rst-out(FIFO)queuebymethods
Enqueue
and
Dequeue
,ora
last-in-rst-out(LIFO)stackbymethods
Push
and
Pop
. Infact,
Push
hasthesame
effectas
Enqueue
whereas
Pop
and
Dequeue
removeitemsfromoppositeendsofthe
circularqueue(orstack).AcircularqueuehasefcientO(1)itemaccessbyindexin
contrasttoqueuesbasedonlinkedlists. Foracircularqueue
cq
,theitem
cq[0]
is
therst(oldest)iteminthequeue,theonethatwillbereturnedbythenextcallto
cq.Dequeue()
.
ClassCircularQueue<T>hastwoconstructors:
CircularQueue<T>()
createsacircularqueuewithadefaultinitialcapacity.
CircularQueue<T>(int capacity)
creates a a circular r queuewith at least the
given initial capacity. . The e circular queuewill l grow as neededwhen items
areadded.
6.2 Arraylists
ClassArrayList<T>implementsinterfacesIList<T>(seesections 1.4.11and4.8),
IStack<T>(sections1.4.9and4.14)andIQueue<T>(sections1.4.10and4.11)using
aninternalarraytostorethelistitems.Itemaccessbyindex
i
takestimeO(1),or
constanttime,regardlessof
i
,butinsertionofoneormoreitemsatposition
i
takes
timeO(Count i),proportionaltothenumberofitemsthatmustbemovedtomake
roomforthenewitem.
Method
Add(x)
adds
x
at theendofthelist. . The
Remove()
methodby default
removesandreturnsthearraylist’slastitem,sothedefaultvalueofthe
FIFO
prop-
ertyisfalse.Anarraylistallowsduplicates,so
AllowsDuplicates
istrue,andstores
duplicatesexplicitly,so
DuplicatesByCounting
isfalse.The
IsFixedSize
propertyis
false,soinsertionanddeletionissupported. The
Sort
methodonArrayList<T>is
introspectivequicksort,aversionofquicksortguaranteedtobeefcient.
ClassArrayList<T>hasfourconstructors:
ArrayList<T>()
createsanarraylistwithadefaultinitialcapacityandade-
faultitemequalitycomparer.
ArrayList<T>(SCG.IEqualityComparer<T> eqc)
createsanarraylistwithade-
faultinitialcapacityandthegivenitemequalitycomparer. ThrowsNullRef-
erenceExceptionif
eqc
is
null
.
ArrayList<T>(int capacity)
createsanarraylistwithatleastthegivenini-
tialcapacityandadefaultitemequalitycomparer.
C# Word: How to Compress, Decompress Word in C#.NET Projects
a C# project in your VS program, you can simply copy below to compress the Word document file to a powerful & profession imaging controls, PDF document, image
can a pdf file be compressed; change paper size in pdf
C# Image: How to Encode & Decode JPEG 2000 Images Using C#.NET JP2
JPEG 2000 image codec SDK has provided can also help and decompress JPEG 2000 image file from local powerful & profession imaging controls, PDF document, image
best pdf compression tool; adjust pdf size preview
112 Hashedarraylists
§6.4
ArrayList<T>(int capacity, , SCG.IEqualityComparer<T> > eqc)
createsanarray
listwithat leastthegiveninitialcapacityandwith thegivenitemequality
comparer.ThrowsNullReferenceExceptionif
eqc
is
null
.
6.3 Linkedlists
ClassLinkedList<T>implementsinterfacesIList<T>(sections1.4.11and4.8),IStack<T>
(sections1.4.9and4.14)andIQueue<T>(sections1.4.10and4.11)usingadoubly-
linkedlistofinternalnodestostorethelistitems. Insertionofanitematagiven
pointinthelisttakestimeO(1),orconstanttime,butgettingtothatpointbyin-
dexingmaytakelineartime. Itemaccessbyindex
i
takestimeproportionaltothe
distancefromthenearestendofthelist,morepreciselyO(min(i;Count i)),andso
isfastonlyneartheendsofthelist.
Method
Add(x)
adds
x
attheendofthelist.The
Remove()
methodbydefaultre-
movesandreturnsthelinkedlist’srstitem,sothedefaultvalueofthe
FIFO
prop-
ertyistrue.Alinkedlistallowsduplicates,so
AllowsDuplicates
istrueandmethod
Add
alwaysreturnstrue.Duplicatesarestoredexplicitly,soproperty
DuplicatesByCounting
isfalse. The
IsFixedSize
propertyisfalse,soinsertionanddeletionissupported.
The
Sort
methodonLinkedList<T>isanin-placemergesort,whichisstable.
ClassLinkedList<T>hastwoconstructors:
LinkedList<T>()
createsalinkedlistwithadefaultitemequalitycomparer.
LinkedList<T>(SCG.IEqualityComparer<T> eqc)
createsalinkedlistwiththe
givenitemequalitycomparer.ThrowsNullReferenceExceptionif
eqc
is
null
.
6.4 Hashedarraylists
ClassHashedArrayList<T>implementsIList<T>(section1.4.11)andisverysimi-
lartoanordinaryarraylist(section6.2),butinadditionmaintainsahashtableso
thatitcanquicklyndthepositionofagiveniteminthearraylist.Itemlookupby
itemvalueusingthe
IndexOf(x)
and
ViewOf(x)
methodstaketimeO(1),orconstant
time,thankstothishashtable.
Incontrasttoanordinaryarraylist,ahashedarraylistdoesnot allowdupli-
cates,soproperty
AllowsDuplicates
isfalse. Asforanordinaryarraylist,thede-
faultvalueofthe
FIFO
propertyandthe
IsFixedSize
propertyarefalse.
ClassHashedArrayList<T>hasfourconstructors:
HashedArrayList<T>()
createsanarraylistwithadefaultinitialcapacityand
adefaultitemequalitycomparer.
HashedArrayList<T>(SCG.IEqualityComparer<T> eqc)
createsanarraylistwith
adefaultinitialcapacityandthegivenitemequalitycomparer. ThrowsNull-
ReferenceExceptionif
eqc
is
null
.
VB.NET Image: RasterEdge JBIG2 Codec Image Control for VB.NET
compressed bitonal images into PDF files and decompress images from PDF files quickly with the smallest quality loss. The encoded images in PDF file can also
change font size on pdf text box; change font size in pdf file
VB.NET Image: JPEG 2000 Codec for Image Encoding and Decoding in
For example, you can use our VB.NET image online Integrate PDF, Tiff, Word compression add-on with JPEG 2000 and lossless compression in the same file stream.
change font size pdf fillable form; change font size in fillable pdf
§6.6
Hashedlinkedlists 113
HashedArrayList<T>(int capacity)
createsanarraylistwithatleastthegiven
initialcapacityandadefaultitemequalitycomparer.
HashedArrayList<T>(int capacity, SCG.IEqualityComparer<T> eqc)
createsan
arraylistwithatleastthegiveninitialcapacityandthegivenitemequality
comparer.ThrowsNullReferenceExceptionif
eqc
is
null
.
6.5 Hashedlinkedlists
ClassHashedLinkedList<T>implementsIList<T>(sections1.4.11and4.8)andis
verysimilartoanordinarylinkedlist(section6.3),butinadditionmaintainsahash
tablesothatitcanquicklyndthepositionofagiveniteminthelinkedlist.Item
lookupbyitemvalueusingthe
ViewOf(x)
methodtakestimeO(1),orconstanttime,
thankstothishashtable. Findingtheindexofagivenitemusingthe
IndexOf(x)
methodtakestimeO(n),proportionaltothelengthofthelist.
Incontrast toan ordinary linkedlist, , ahashedlinked listdoes not t allow du-
plicates,soproperty
AllowsDuplicates
isfalse. Asforanordinarylinkedlist,the
defaultvalueofthe
FIFO
propertyistrueandthe
IsFixedSize
propertyisfalse.
ClassHashedLinkedList<T>hastwoconstructors:
HashedLinkedList<T>()
createsalinkedlistwithadefaultitemequalitycom-
parer.
HashedLinkedList<T>(SCG.IEqualityComparer<T> eqc)
createsalinkedlistwith
thegivenitemequality comparer. . ThrowsNullReferenceExceptionif
eqc
is
null
.
6.6 Wrappedarrays
ClassWrappedArray<T>implementsIList<T>(section1.4.11and4.8)andprovides
awaytowrapanordinaryone-dimensionalarrayoftypeT[]asaxed-sizearray
list(section6.2). TheprimaryuseofwrappedarraysistoallowallIList<T>func-
tionality,in particularviews,search andreordering, tobeusedonordinaryone-
dimensionalarrays.
Wrappingan arrayasa WrappedArray<T>doesnotcopythearray,andisan
O(1),orconstanttime,operation.Subsequentupdatestotheunderlyingarrayshow
throughtotheWrappedArray<T>,andviceversa.Updatestotheunderlyingarray
donotraiseevents,whereasupdatesthroughthewrapperdo. MostIList<T>op-
erations,includingthecreationofviews,workalsoforWrappedArray<T>,butnot
those methods s that wouldcausethe e collection to grow w or shrink. . In n particular,
Add
,
Clear
,
FIFO
,
Insert
,
Remove
,and
RemoveAt
donotwork,butwill throwFixed-
SizeCollectionException.Bycontrast,operationssuchas
Reverse
,
Shuffle
and
Sort
C# TIFF: How to Insert & Burn Picture/Image into TIFF Document
level model to demonstrate pages in all document file. Our .NET TIFF Processing Toolkit can be incorporated & profession imaging controls, PDF document, tiff
reduce pdf file size; reader pdf reduce file size
VB.NET Image: Free VB.NET Guide to Convert Image to Byte Array
If necessary, you can also use this VB.NET Image Conversion Control to convert Word or PDF document to image file in VB.NET application.
pdf compressor; can pdf files be compressed
114 Sortedarrays
§6.7
dowork:althoughtheychangethecollection,theydonotchangeitssize. Allsup-
portedoperationshavethesamerunningtimeasforArrayList<T>.
Theproperties
AllowsDuplicates
and
IsFixedSize
aretrue.
ClassWrappedArray<T>hasoneconstructor:
WrappedArray<T>(T[] arr)
createsawrappedarraylistwhoseunderlyingar-
rayis
arr
.Itisnotread-only,butithasxedsize:its
Count
isxedandequals
arr.Length
.ThrowsNullReferenceExceptionif
arr
is
null
.
WrappedArray<T>(T[] arr, SCG.IEqualityComparer<T> eqc)
createsawrapped
arraylistwhoseunderlyingarrayis
arr
. Itisnotread-only,butithasxed
size:its
Count
isxedandequals
arr.Length
.ThrowsNullReferenceException
if
arr
or
eqc
is
null
.
6.7 Sortedarrays
ClassSortedArray<T>implementsinterfaceIIndexedSorted<T>(seesections1.4.6
and4.7). Asortedarrayissimilartoan n array listbecauseitsupports indexing,
FindIndex
,andsoon, but t different becauseitdoes not supportlistviews,
First
,
Last
,
Shuffle
andsoon. Incontrasttoanarraylist,asortedarraykeepsitsitems
sortedanddoesnotallowduplicates,soproperty
AllowsDuplicates
isfalse.
ClassSortedArray<T>hasthefollowingconstructors:
SortedArray<T>()
createsanewsortedarraywithadefaultinitialcapacity,a
defaultitemcomparer,andadefaultitemequalitycomparer.Thedefaultitem
comparerusesthenaturalcomparerforT;ifTdoesnotimplementICompara-
ble<T>orIComparable,thenNotComparableExceptionisthrown.
SortedArray<T>(int capacity)
creates a newsortedarray withatleastthe
given initial capacity, a defaultitem comparer, and a default itemequality
comparer.
SortedArray<T>(SCG.IComparer<T> cmp)
createsanewsortedarraywithade-
faultcapacity,thegivenitemcomparer,andadefaultitemequalitycomparer.
ThrowsNullReferenceExceptionif
cmp
is
null
.
SortedArray<T>(int capacity, SCG.IComparer<T> cmp)
creates a new sorted
arraywithatleastthegivencapacity,thegivenitemcomparer,andadefault
itemequalitycomparer.ThrowsNullReferenceExceptionif
cmp
is
null
.
SortedArray<T>(int capacity, SCG.IComparer<T> cmp, SCG.IEqualityComparer<T>
eqc)
createsanewsortedarraywithatleastthegivencapacity,thegivenitem
comparer,andthegivenitemequalitycomparer.ThrowsNullReferenceExcep-
tionif
cmp
or
eqc
is
null
.
VB.NET PowerPoint: How to Convert PowerPoint Document to TIFF in
can be compressed to reduce the file size by using LZW compression and can be converted to many other image and document formats, such as JPEG, GIF and PDF, by
change page size pdf acrobat; pdf form change font size
JPEG to PDF Converter | Convert JPEG to PDF, Convert PDF to JPEG
JPEG to PDF Converter can be used on Windows 95, Windows 98, Windows ME of JPG to PDF with amazingly high speed; Get a compressed PDF file after conversion;
change paper size pdf; change font size in pdf comment box
§6.9
Tree-basedsets 115
Theitemcomparerisusedtodetermineitemequalityanditemorderinthesorted
array. Theitemequalitycomparerisusedonlytodeneanequalitycomparerfor
theentiresortedarray.Thisisuseful,forinstance,ifthesortedarrayisusedasan
iteminahash-basedcollection: Anequalitycomparermaybemuchfasterthana
comparer..Forinstance,twostringsofdifferentlengthareclearlynotequal,butif
theyhavealongprexincommon,itmaybeinefcientforacomparertodetermine
whichoneislessthantheotherone.
Efciencywarning:RandominsertionsanddeletionsonalargeSortedArray<T>
areslowbecauseallitemsaftertheinsertionordeletionpoint mustbemovedat
eachinsertionordeletion.UseaTreeSet<T>ifyouneedtomakerandominsertions
anddeletions ona sortedcollection. . Use e SortedArray<T>only ifthenumber of
itemsissmallorifthesortedarrayismodiedrarelybutisaccessedfrequentlyby
itemindexoritemvalue.
6.8 Tree-basedsets
ClassTreeSet<T>implementsinterfacesIIndexedSorted<T>(sections1.4.6and4.7)
andIPersistentSorted<T>(sections1.4.8and4.9)andrepresentsasetofitemsus-
ingabalancedred-blacktree; seesection13.10. . Itemaccessbyindexorbyitem
valuetakestimeO(logn),anditeminsertionanditemdeletiontaketimeO(logn)
amortized. Atreesetdoesnotallowduplicates,sotheproperty
AllowsDuplicates
isfalse. Fromatree-basedset,onecanefcientlymakeasnapshot,orpersistent
copy;seesection8.5.
ClassTreeSet<T>hasthreeconstructors:
TreeSet<T>()
createsanewtreesetwithadefaultitemcomparerandadefault
itemequalitycomparer.Thedefaultitemcomparerusesthenaturalcomparer
forT;ifTdoesnotimplementIComparable<T>orIComparable,thenNotCom-
parableExceptionisthrown.
TreeSet<T>(SCG.IComparer<T> cmp)
createsanewtreesetwiththegivenitem
comparerandadefaultitemequalitycomparer.ThrowsNullReferenceExcep-
tionif
cmp
is
null
.
TreeSet<T>(SCG.IComparer<T> cmp, SCG.IEqualityComparer<T> eqc)
createsa
newtreesetwiththegivenitemcomparerandthegivenitemequalitycom-
parer.ThrowsNullReferenceExceptionif
eqc
is
null
.
Theitemcompareris usedtodetermineitemequalityanditemorderinthetree
set.Theitemequalitycomparerisusedonlytodeneanequalitycomparerforthe
entiretreeset. Thisisneeded,forinstance,ifthetreesetisusedasanitemina
hash-basedcollection.
116 Hashsets
§6.10
6.9 Tree-basedbags
ClassTreeBag<T>implementsinterfacesIIndexedSorted<T>(sections1.4.6and4.7)
andIPersistentSorted<T>(sections1.4.8and4.9)andrepresentsabag,ormultiset,
ofitemsusingabalancedred-blacktree.Itemaccessbyindexorbyitemvaluetakes
timeO(logn),anditeminsertionanditemdeletiontaketimeO(logn)amortized.
Atreebagallowsduplicates,sotheproperty
AllowsDuplicates
istrue,andonly
onerepresentativeforeachitemequivalenceclassisstored,so
DuplicatesByCounting
istrue.
Fromatree-basedbag,onecanefcientlymakeasnapshot,orpersistentcopy;
seesection8.5.
ClassTreeBag<T>hasthreeconstructors:
TreeBag<T>()
createsanewtreebagwithadefaultitemcomparerandade-
fault itemequality comparer. . The e default t item compareruses thenatural
comparerfor T;if f Tdoes s not implement IComparable<T> or IComparable,
thenNotComparableExceptionisthrown.
TreeBag<T>(SCG.IComparer<T> cmp)
createsanewtreebagwiththegivenitem
comparerandadefaultitemequalitycomparer.ThrowsNullReferenceExcep-
tionif
cmp
is
null
.
TreeBag<T>(SCG.IComparer<T> cmp, SCG.IEqualityComparer<T> eqc)
createsa
newtreebagwiththegivenitemcomparerandthegivenitemequalitycom-
parer, which mustbecompatible. . Throws s NullReferenceException if
eqc
is
null
.
Theitemcomparerisusedtodetermineitemequalityanditemorderinthetree
bag.Theitemequalitycomparerisusedonlytodeneanequalitycomparerforthe
entiretreebag. Thisisneeded,forinstance,ifthetreebagisusedasanitemina
hash-basedcollection.
6.10 Hashsets
Class HashSet<T> implements interfaceIExtensible<T> (sections 1.4.3 and4.5)
and represents s a set ofitems using a a hash h tablewith linear chaining; ; see e sec-
tion13.4. ItemaccessbyitemvaluetakestimeO(1),anditeminsertionanditem
deletiontaketimeO(1)amortized. Ahash h set does not allow duplicates, sothe
property
AllowsDuplicates
isfalse.
ClassHashSet<T>hasfourconstructors:
HashSet<T>()
createsanew hashsetwitha defaultinitialtablesize(16),a
defaultllthreshold(0.66),andadefaultitemequalitycomparer.
HashSet<T>(SCG.IEqualityComparer<T> eqc)
createsanewhashsetwithade-
faultinitialtablesize(16),adefaultllthreshold(0.66),andthegivenitem
equalitycomparer.ThrowsNullReferenceExceptionif
eqc
is
null
.
§6.11
Hashbags 117
HashSet<T>(int capacity, SCG.IEqualityComparer<T> eqc)
createsanewhash
setwiththegiveninitialtablesize,adefaultllthreshold(0.66),andthegiven
itemequalitycomparer.ThrowsArgumentExceptionif
capacity <= 0
.Throws
NullReferenceExceptionif
eqc
is
null
.
HashSet<T>(int capacity, double fill, , SCG.IEqualityComparer<T> > eqc)
cre-
atesanewhashsetwiththegiveninitialtablesize,thegivenllthreshold,
andthegivenitemequalitycomparer.ThrowsArgumentExceptionif
capacity
<= 0
orif
fill < < 0.1
or
fill > > 0.9
. ThrowsNullReferenceExceptionif
eqc
is
null
.
InadditiontothemethodsdescribedbytheinterfacesimplementedbyHashSet<T>,
ithasonemethod:
ISortedDictionary<int,int>
BucketCostDistribution
()
returnsanewta-
ble
bcd
reportingthecurrentbucketcostdistributionintheinternalrepresen-
tationofthehashset.Thevalueof
bcd[c]
isthenumberofbucketsthathave
cost
c
.The
bcd
tablecanbeusedtodiagnosewhetheraperformanceproblem
maybeduetoabadchoiceofhashfunction.
Abucketinahashtableisanequivalenceclassofitemswhosehashvalues
maptothesameentryinthehashtable,forthecurrenttablesize. Thecost
ofabucketisthenumberofequalitycomparisonsthatmustbeperformedby
theitemequalitycomparertodeterminethatanitemisnotamemberofthe
bucket.Thisisthenumberofequalitycomparisonsmadewhenalookupfails.
Thelargestbucketcostofahashtablegivesanupperboundontheexecution
timeofahashtablelookup. Alargebucketcostis s causedbya poorchoice
ofhashfunctionforthegivendistributionofitems. Inparticular,ifthehash
functiongivesallitemsthesameconstanthashcode,thenthetablewillhave
asinglebucketwithaverylargecost.
Forgoodperformance,ahashtableshouldonlyhavebucketswithlowbucket
cost. Use
BucketCostDistribution.Keys.FindMax()
tondthelargestbucket
costinthehashset.Asaruleofthumbthisnumbershouldnotbemorethan
25. Seeantipattern131 1 fortypical bucketcostdistributions resultingfrom
goodandbadhashfunctions.
6.11 Hashbags
ClassHashBag<T>implementsinterfaceIExtensible<T> (sections 1.4.3 and4.5)
andrepresentsabag(multiset)ofitemsusingahashtablewithlinearprobing.Item
accessbyitemvaluetakestimeO(1),anditeminsertionanditemdeletiontaketime
O(1)amortized.Ahashbagallowsduplicates,sotheproperty
AllowsDuplicates
is
true,butduplicateitemsarenotstoredexplicitly,onlythenumberofduplicates,so
DuplicatesByCounting
istrue.
ClassHashBag<T>hasfourconstructors:
118 Intervalheapsorpriorityqueues
§6.12
HashBag<T>()
createsanewhashbagwithadefaultinitialtablesize(16),a
defaultllthreshold(0.66),andadefaultitemequalitycomparer.
HashBag<T>(SCG.IEqualityComparer<T> eqc)
createsanewhashbagwithade-
faultinitialtablesize(16),adefaultllthreshold(0.66),andthegivenitem
equalitycomparer.ThrowsNullReferenceExceptionif
eqc
is
null
.
HashBag<T>(int capacity, SCG.IEqualityComparer<T> eqc)
createsanewhash
bag withthegiveninitial tablesize, a default ll threshold(0.66), andthe
givenitemequalitycomparer. ThrowsArgumentExceptionif
capacity <= 0
.
ThrowsNullReferenceExceptionif
eqc
is
null
.
HashBag<T>(int capacity, double fill, SCG.IEqualityComparer<T> eqc)
cre-
atesanewhashbagwiththegiveninitialtablesize,thegivenllthreshold,
andthegivenitemequalitycomparer.ThrowsArgumentExceptionif
capacity
<= 0
orif
fill < < 0.1
or
fill > > 0.9
.ThrowsNullReferenceExceptionif
eqc
is
null
.
6.12 Intervalheapsorpriorityqueues
Class IntervalHeap<T> implements interface e IPriorityQueue<T>(sections s 1.4.12
and 4.10) using g an interval heapstoredas an array y ofpairs. . The
FindMin
and
FindMax
operations,andtheindexer’sget-accessor,taketimeO(1). The
DeleteMin
,
DeleteMax
,
Add
and
Update
operations, and the e indexer’s set-accessor, , take time
O(logn).Incontrasttoanordinarypriorityqueue,anintervalheapoffersbothmin-
imumandmaximumoperations withthesameefciency. . The
AllowsDuplicates
propertyistrue,and
DuplicatesByCounting
is false. . Seesection n 13.11 forimple-
mentationdetails.
ClassIntervalHeap<T>hasfourconstructors:
IntervalHeap<T>()
createsa new interval heapwitha default capacity (16)
and a a default item m comparer. . Thedefault t item comparer uses thenatural
comparerfor T;if f Tdoes s not implement IComparable<T> or IComparable,
thenNotComparableExceptionisthrown.
IntervalHeap<T>(SCG.IComparer<T> cmp)
createsa newintervalheapwitha
defaultcapacity(16)andthegivenitemcomparer. ThrowsNullReferenceEx-
ceptionif
cmp
is
null
.
IntervalHeap<T>(int capacity)
createsanewintervalheapwithatleastthe
givencapacityandadefaultitemcomparer. Thedefaultitemcompareruses
thenaturalcomparerforT;ifTdoesnotimplementIComparable<T>orICom-
parable,thenNotComparableExceptionisthrown.
IntervalHeap<T>(int capacity, SCG.IComparer<T> cmp)
createsa newinter-
valheapwithatleastthegivencapacityandwiththegivenitemcomparer.
ThrowsNullReferenceExceptionif
cmp
is
null
.
Documents you may be interested
Documents you may be interested