13.5 DequeOperations
157
EXAMPLE(77)
Anexampleexplainingsomearrayoperations.
1
functionarrayExample(ref ai:array<int>):boolean
2
{
3
defrefa:array<int> =array<int>[];
4
a.add(1); // [1 ]
5
a.add(2); // [1,2 ]
6
a.add(3); // [1,2, 3 ],a.size()==3
7
defvartmp:int =a.peek(); // endof[ 1,2,3 ]is3
8
a.rem();//[ 1, 2] FIFO
9
for(k:int -> v:intina){
10
ai.add(v); // ai[k] ==a[k]
11
}//a == ai == [1, 2 ],assuminginput was[]
12
defvari:int= a.indexOf(2);
13
if(i!=-1){ // a[i]==2
14
a[i]= 3;
15
}//[ 1, 3]
16
a.add(2,1); // [1, 2, 3]
17
return(2 in (a +array<int>[ 4, 5]));//true
18
}
13.5 DequeOperations
Deque expressions consist of deque membershipchecking, deque value lookup, and deque
concatenation,plussomeoperationsinmethodcallnotation.
DequeExpr
-
PrimaryExpr
-
MethodSelector
-
Expr
-
in
-
DequeExpr
-
DequeExpr
-
[
-
Expr
-
]
-
DequeExpr
-
DequeOperator
-
DequeExpr
-
MethodCall
-
DequeEntity
-
MethodSelector
-
Assignment
-
DequeEntity
-
=
-
DequeExpr
-
IndexedAssignment
-
DequeEntity
-
[
-
IndexExpr
-
]
-
=
-
Expr
-
CompoundAssignment
-
DequeEntity
-
DequeOperator
-
=
-
Expr
-
ChangeAssignment
-
To jpeg - Convert PDF to JPEG images in C#.net, ASP.NET MVC, WinForms, WPF project
How to convert PDF to JPEG using C#.NET PDF to JPEG conversion / converter library control SDK
convert pdf to jpg for online; change pdf to jpg file
To jpeg - VB.NET PDF Convert to Jpeg SDK: Convert PDF to JPEG images in vb.net, ASP.NET MVC, WinForms, WPF project
Online Tutorial for PDF to JPEG (JPG) Conversion in VB.NET Image Application
change file from pdf to jpg; change pdf to jpg format
158
ContainerTypesandComputations
DequeConstructor
-
deque
-
<
-
Type
-
>
-
]
-
Expression
,
-
[
-
Thequerymethodcallsondequesare:
.size()
returnsthenumberofelementsinthedeque,asint
.empty()
returnswhetherthedequeisempty,asboolean
.peek(num)
returnsthevaluestoredinthedequeatpositionnum:intinthesequenceofenumera-
tion,isequivalentto(andimplementedby)a[num]);retrievaloccursinconstanttime.
.peek()
returnstherstvaluestoredinthedeque;retrievaloccursinconstanttime.
.indexOf(valueToSearchFor)
returnsrstpositionvalueToSearchFor:Tappearsat,asint,or-1ifnotfound
.indexOf(valueToSearchFor, startIndex)
returns therstpositionvalueToSearchFor:Tappears at,whenwe start the search
foritatdequepositionstartIndex:int,asint,or-1ifnotfound
.lastIndexOf(valueToSearchFor)
returnslastpositionvalueToSearchFor:Tappearsat,asint,or-1ifnotfound
.subdeque(startIndex, length)
returnssubdequeofgivenlength:intfromstartIndex:inton
.asArray()
returnsanarrayofthedequecontent,asarray<T>fordeque<T>,insameorder
.asSet()
returnsasetofthedequecontent,asset<T>fordeque<T>
Theupdatemethodcallsondequesare:
Dequeaddition:
d.add(v)addsthevaluevtotheendofdequed.
Dequeaddition:
d.add(v,i)insertsthevaluevatindexitodequed.
Dequeremoval:
d.rem()removesthevalueatthenbeginofthedequed.
Dequeremoval:
d.rem(i)removesthevalueatindexifromthedequed.
Online Convert Jpeg to PDF file. Best free online export Jpg image
Online JPEG to PDF Converter. Download Free Trial. Convert a JPG to PDF. You can drag and drop your JPG file in the box, and then start
convert pdf image to jpg online; .pdf to .jpg online
Online Convert PDF to Jpeg images. Best free online PDF JPEG
Online PDF to JPEG Converter. Download Free Trial. Convert a PDF File to JPG. Drag and drop your PDF in the box above and we'll convert the files for you.
reader pdf to jpeg; conversion of pdf to jpg
13.5 DequeOperations
159
Dequeclearing:
d.clear()removesallvaluesfromthedequed.
Thebinarydequeoperatorsare:
+
Dequeconcatenation:returnsnewdequewiththerightappendedtotheleftdeque
theleftandrightoperandsmustbeofidenticaltypedeque<T>
Table13.8:Binarydequeoperators,inascendingorderofprecedence
The operator r x x in d d denotes s deque e value membership, , returning g whether r the deque
contains the givenelement, , as s boolean. . It t is aO(n) operationfor deques. . Theoperator
d[x] denotes s deque e lookup, i.e. . it t returns the value y whichis stored d inthe deque d d at
theindexx. Theindexxmust t beavaliddequeindex. . Furthermore,thecontainermaybe
iteratedoverwitha forloop,asintroducedin12.3. Thedeque e allows fornon-indexedas
wellasindexediteration;ifnon-indexediterationisusedthedequevaluesareiteratedover,
ifindexediterationisusedtheindexisassignedtotheindexvariableandthecorresponding
valueisassignedtothevaluevariable.
Therelationalexpressions(alreadyintroducedin6.4)usedtocompareenititesofdierent
kinds,mappingthemtothetypeboolean,are extendedtosets accordingtotable13.9: A
dequeAisasubdequeof Biitissmalleror equalinsizeandthevaluesateachcommon
indexareidentical(lexicographicorderasforstrings).
A == B
True,iAandBareidentical.
A != B
True,iAandBarenotidentical.
A < < B
True,iAisasubdequeofB,butAandBarenotidentical.
A > > B
True,iAisasuperdequeofB,butAandBarenotidentical.
A <= B
True,iAisasubdequeofBorAandBareidentical.
A >= B
True,iAisasuperdequeofBorAandBareidentical.
Table13.9:Binarydequeoperatorsforcomparison
Theassignmentsimplementthecomputationconstructsintroducedin12. Thepureas-
signmentoverwritesthetargetdequewiththesourcedeque,commonlywithvaluesemantics,
creatingacopyofthesourcedeque.Onlyifalocalvariable(i.e.notanattribute)isassigned
toalocalvariable,is reference semantics used(i.e. . bothvariables s point afterwards tothe
samedeque). The e indexedassignment d[i]=v overwrites theoldvalue at index i i inthe
dequedwiththenewvaluev. Compoundassignmentsareassignmentswhichusetherst
sourceastarget,too,onlyadaptingthetargetvalueinsteadofcomputinganewvalueand
overwritingthetargetwithit. Forscalarsthisisnotsupported,butforcontainervalueden-
titiesitisoeredduetothepotentialformassivecomputationalcostsavings.Thecompound
assignmentstatementondequesistheconcatenationassignment+=.
TheDequeConstructor extends s theLiteral l from6.8(asarenement t oftheContainer-
Constructor there). . Itis s constantifonlyprimitivetypeliterals,enumliterals,orconstant
expressions are used; ; this s is requiredfor container initializations inthemodel. . Itis s non-
constantifitcontainsnodes/edges/ormemberaccesses,whichmaybethecaseifusedinthe
rules. Theelementsgiveninthetypeconstructorarecastedtothespeciedmembertypes
ifneededandpossible.
C# HTML5 Viewer: Load, View, Convert, Annotate and Edit Raster
Raster Images File Formats. • C#.NET RasterEdge HTML5 Viewer supports various images formats, including JPEG, GIF, BMP, PNG, etc. Loading & Viewing.
convert pdf to gif or jpg; conversion pdf to jpg
C# Raster - Convert Image to JPEG in C#.NET
C# Raster - Convert Image to JPEG in C#.NET. Online C# Guide for Converting Image to JPEG in .NET Application. Convert RasterImage to JPEG.
convert pdf file to jpg online; best way to convert pdf to jpg
160
ContainerTypesandComputations
NOTE(38)
The double ended d queue e allows for fast addition n and removal both at the frond and at
the back,incontrasttoarraysthat only support thisatthe end. . It t is implementedbya
ringbuerthatisgrownasneeded,alookupisslightlymoreexpensivethananarraylookup.
Theprimaryusageofthedequeis as aqueue,as neededforbreadthrstsearch,accessed
FIFO(rst-inrst-out). Thisisincontrasttothearraythatissuitedtobeemployedasa
stack,e.g. inadepthrstsearch(unlessthatisprogrammedusingthecallstack),accessed
LIFO(last-inrst-out).
EXAMPLE(78)
Anexampleexplainingsomedequeoperations.
1
functiondequeExample(ref di:deque<int>):boolean
2
{
3
defrefd:deque<int> =deque<int>][;
4
d.add(1); // ]1 [
5
d.add(2); // ]1,2 [
6
d.add(3); // ]1,2, 3 [,d.size()==3
7
defvartmp:int =d.peek(); // begin of ]1, 2, 3[ is 1
8
d.rem();//] 2, 3[ LIFO
9
for(k:int -> v:intind){
10
di.add(v); // di[k] ==d[k]
11
}//d == di == ]2, 3 [,assuminginput was][
12
defvari:int= d.indexOf(2);
13
if(i!=-1){
14
d[i]= 1;
15
}//] 1, 3[
16
d.add(2,1); // ]1, 2, 3[
17
return(2 in (d +deque<int>] 4, 5[));//true
18
}
13.6 StorageAccessintheRules
Storagescanbeusedintheruleapplicationcontrollanguageasintroducedabove17.4,they
cangetlledoremptiedintherulesasdenedhere5.4.3,adiscussionabouttheirusageand
examplesaregivenhere19,here19.5,andhere19.6. Inthepatternpartyoumayaskforan
elementtogetboundtoanelementfromastorageorastorageattribute;thisissyntactically
speciedbygivingthestorageenclosedinleftandrightbracesaftertheelementdeclaration.
Youmayaskforanelement togetboundtothevalueelementqueriedfromastoragemap
byakeygraphelement;thisissyntacticallyspeciedbygivingthestoragemapindexedby
thekeygraphelementenclosedinleftandrightbraces(thisisnotpossibleforstoragemap
attributesduetointernallimitationswiththesearchplanning). Ifthetypeoftheelement
retrievedfromthestorageisnotcompatibletothetypeofthepatternelementspecied,or
ifthestorageisempty,or ifthekeyelementis notcontainedinthestoragemap,matching
fails.
Theadvantageofthisstoragequeryinginsidetheruleoverhandinginavaluefromafor
loopiteratingthestoragevaluesoutsidetheruleare:i)amoreconcisesyntax,ii)theability
toaccessastorageattributeofanelementjustmatchedortoaccessastoragemapwithan
elementjustmatchedinthesamerule,whichwouldrequiretobreakuptheruleintworules
inthe other case,andiii), arestriction oftheiteration tothe matchingphase,sothat at
.NET JPEG 2000 SDK | Encode & Decode JPEG 2000 Images
RasterEdge .NET Image SDK - JPEG 2000 Codec. Royalty-free JPEG 2000 Compression Technology Available for .NET Framework.
best pdf to jpg converter for; .pdf to jpg converter online
C# TIFF: How to Convert TIFF to JPEG Images in C# Application
C# Demo to Convert and Render TIFF to JPEG/Png/Bmp/Gif in Visual C#.NET Project. C#.NET Image: TIFF to Raster Images Overview. C#.NET Image: TIFF to JPEG Demo.
change pdf to jpg on; pdf to jpeg converter
13.7 Hintsoncontainerusage
161
rewritingonecanhappilymanipulatethestoragewithoutdestroyingtheiterator/enumerator
usedintheloopwhichwouldbethecasewhenusinganoutsideloop.
ThefollowingsyntaxdiagramgivesanextensionstothesyntaxdiagramsoftheRuleSet
Languagechapter5,patternpart:
StorageAccess
-
f
-
StorageVariable
-
g
-
f
-
NodeOrEdge
-
.
-
StorageAttribute
-
g
-
f
-
StorageMap
-
[
-
Ident
-
]
-
g
-
EXAMPLE(79)
Queriesthegraphfortheneighbouringcitiestothecitiescontainedinthestorageset.
1
testneighbour(refstartCities:set<City>): City
2
{
3
:City{startCities}-:Street-> n:City;
4
return(n);
5
}
EXAMPLE(80)
Queries for the neighbour of theneighbourofa city matched. . Withtherstneighboring
relationqueriedfromthestoragemapassumedtocontaintheneighbouringrelationofsome
citiesofinterest,andthesecondneighbouringrelationqueriedfromthegraph.
1
testneighbourneighbour(refneighbours:map<City,City>): City
2
{
3
someCity:City;
4
nc:City{neighbours[someCity]} -:Street->nnc:City;
5
return(nnc);
6
}
13.7 Hintsoncontainerusage
Acontaineriteratedovermuststayunchangedduringtheiteration. Butsometimeswewant
tochangetheiteratedcontent,e.g.lterthecontainerduringiteration. Asremedythecopy
functionmay beusedtoclone the container before the iteration,so thattheclonecanbe
iteratedoverandtheoriginalcontainerchanged.
copy(set<T>):set<T>
returnsacloneoftheoriginalsetgivenasargument.
copy(map<S,T>):map<S,T>
returnsacloneoftheoriginalmapgivenasargument.
copy(array<T>):array<T>
returnsacloneoftheoriginalarraygivenasargument.
C# Word - Convert Word to JPEG in C#.NET
C# Word - Convert Word to JPEG in C#.NET. C#.NET Word to JPEG Converting & Conversion Control. Word to JPEG Conversion Overview. Convert Word to JPEG Using C#.NET
convert pdf image to jpg image; convert pdf to jpg
C# powerpoint - Convert PowerPoint to JPEG in C#.NET
C# PowerPoint - Convert PowerPoint to JPEG in C#.NET. C#.NET PowerPoint to JPEG Converting & Conversion Control. PowerPoint to JPEG Conversion Overview.
pdf to jpg; .net convert pdf to jpg
162
ContainerTypesandComputations
copy(deque<T>):deque<T>
returnsacloneoftheoriginaldequegivenasargument.
EXAMPLE(81)
Thecontainer statechangemethods addandremallowto addgraphelementstostorages
orremovegraphelementsfromstorages,i.e. setsormapsorarraysordequesholdingnodes
andedgesusedforrewriteinthecallingsequence(cf. 17.4). Thiswayyoucanwritetrans-
formationsconsistingofseveralpasses withonepassoperatingonnodes/edges determined
inapreviouspass,withouttheneedtomarktheelement inthe graphby helper edges or
visited ags.
1
rulefoo(ref storage:set<Node>)
2
{
3
n:Node;
4
modify {
5
eval {
6
storage.add(n);
7
}
8
}
9
}
EXAMPLE(82)
Someexamplesofcontainerliterals:
1
set<string>{ "foo", "bar" }//aconstantset<string>constructor
2
map<string,int>{(n.strVal+m.strVal)->(m.intVal+n.intVal),intVal->strVal, "fool"->42} // a
non-constantmapconstructor
3
array<int>[1,2,3] // aconstantarray<int>constructor
4
deque<int>]1,2,3[ // aconstantdeque<int>constructor
CHAPTER 14
GRAPHTYPE AND COMPUTATIONS
14.1 Built-InTypes
Besides the types already introduced, GrGen.NET T oers supports for a graph type. . If
usedexplicitly,itdenotesasubgraphofthehost graph,whichcanbeusedforstoringand
comparingsubgraphsofthecurrenthostgraph. (Becauseofthe"thereisonlyasinglehost
graph"-designofGrGenyoumustexplicitlydescendtothenestedsubgraphifyouintendto
processit,see16.3).
Butmoreimportantarethelargenumberofglobalfunctions(withcallsyntaxasalready
introducedin6.8)andglobalprocedures(withcallsyntaxasalreadyintroducedin12.5.2)
that implicitlyoperate onthesingle host graph(andthusonthe graphtype). . Thereare
updatefunctionsavailablethatallowtomanipulatethegraphavailablewithadd,remand
retype.Thehostgraphmaybequeriedforallnodesoredgesofagiventype.Anedgemay
bequeriedforitssourceandtargetelements,whileanodemaybe queriedfor its direct
neighbourhoodwithallincidentedges, oralladjacent t nodes. . Orevenfor r itstransitive
neighbourhoodwithallreachablenodesoredges. Intheformoffunctionsreturningsets
of nodes or edges, or inthe form of iterations with for loops, or r inthe e form of boolean
predicatestotesttheneighbourhoodiftwoelementsaregiven. Theinducedsubgraphofa
setofnodesoredgesmaybecomputed,ordirectlyinsertedintothehostgraph.
Furthermore, visited d  ags s may y be used d for r marking already visitedelements s during
graphwalksorforpartitioningagraph.Theseoperationsareavailableintherulelanguage,
as function n atoms s of the expression n sublanguage e from 6, and as s procedure atoms s of the
statement sublanguage from 12; most t of themare available inthe sequence computations
language,too(17.1willtellaboutthedierencescomparedtotherulelanguage).
Thegraphmanipulationprocedures,thetransactionhandlingprocedures,andthevisited
agmanagementandassignment procedures arenotavailableinthefunction n abstraction;
theymayonlybecalledfromtheprocedures.
14.2 GraphFunctionsAndProcedures
14.2.1 GraphUpdates/BasicGraphManipulation
Thereareprocedurestoupdatethegraphby addingorremovingor retypingavailable,on
nodesandedges:
add(.)
addsanewnodeofthegivennodetypetothehostgraph,returnstheaddednode.
addCopy(.)
addsacloneoftheoriginalnodetothehostgraph,returnstheaddednode.
add(.,.,.)
addsanewedgeofthegivenedgetypetothehostgraph,inbetweenthesourcenode
163
164
GraphTypeandComputations
speciedassecondargumentandthetargetnodespeciedasthirdargument,returns
theaddededge.
addCopy(.,.,.)
addsacloneoftheoriginaledgetothehostgraph,inbetweenthesourcenodespecied
assecondargumentandthetargetnodespeciedasthirdargument,returnstheadded
edge.
rem(.)
removesthenodeoredgegivenfromthe hostgraph(noexpression,doesnotreturn
anything).
retype(.,.)
retypesthenodeoredgegiventothenodetypeoredgetypegivenassecondargument,
returnstheretypedentity.
clear()
clearsthehostgraph.
Besidsethosebasicgraphmanipulationfunctions,someadvancedrewritingoperationsare
availableasprocedures,too:
merge(.,.)
mergesthesourcenodegivenas secondargumentinto the target node givenas rst
argument.
redirectSource(.,.)
redirects the e edge e given n as rst argument to the new source node given as second
argument.
redirectTarget(.,.)
redirects the e edge e given n as rst argument to the new w target node e given n as s second
argument.
redirectSourceAndTarget(.,.,.)
redirects the e edge e given n as rst argument to the new source node given as second
argumentandthenewtargetnodegivenasthirdargument.
The versions s introduced above e are only y available e onnamed graphs, as s they y fetch h the
debug display name fromthe old element. . If f you want touse them on unnamed graphs
youmustsupplyanadditionalargumentgivingthenameoftheoldelement;incaseofthe
redirectSourceAndTargetyoumustsupplytwoadditionalarguments,rstthestringtouse
fortheoldsourcenodename,thenthestringtousefortheoldtargetnodename.
14.2.2 GraphQuerybyTypes
Therearefunctionstoaskforallnodesoredgesofatypeavailable:
nodes(.)
returnsallnodesinthegraphcompatibletothegivennodetype,asset.
nodes()
returnsallnodesinthegraph,asset.
edges(.)
returnsalledgesinthegraphcompatibletothegivenedgetype,asset.
14.2 GraphFunctionsAndProcedures
165
edges()
returnsalledgesinthegraph,asset.
Thesamefunctionscanbeusedfromforloopstoiterateovertheentities,omittingthe
llingofaset:
for(n:NodyType in nodes(NodeType)) ) fStatementsg
iteratesoverallnodesinthegraphcompatibletothegivennodetype.
for(n:Node in nodes()) fStatementsg
iteratesoverallnodesinthegraph.
for(e:EdgeType in edges(EdgeType)) ) fStatementsg
iteratesoveralledgesinthegraphcompatibletothegivenedgetype.
for(e:Edge in edges()) fStatementsg
iteratesoveralledgesinthegraph.
14.2.3 GraphQuerybyNeighbourhood
Multiplefunctionsareavailabletoquerytheneighbourhoodofnodesandedges.
EdgeNeighbourhood
Thenodesincidenttoagivenedgemaybequeriedbythefollowingfunctions:
source(.)
returnsthesourcenodeofthegivenedge.
target(.)
returnsthetargetnodeofthegivenedge.
opposite(.,.)
returnstheoppositenodeoftheedgeandthenode(secondargument)given.
NodeNeighbourhoodCommonConcepts
Theedgesincidentorthenodesadjacenttoagivennodemaybequeried.
Theneighbourhoodqueryfunctions allowtoadditionally constrainthe directionofthe
edgestoincomingoroutgoingedges,otherwisebothdirectionsareaccepted.
Theneighbourhoodqueryfunctionsfurthermoreallowtoconstraintheacceptedsituations
byoptionalarguments. Thetypetheincidentedgesmust t havetobeaccountedforcanbe
specied. Or r the typetheincident edges must havetobeaccountedforandthe typethe
adjacentnodesmusthavetobeaccountedfor(cf. 14.2.3).
NeighbourhoodFunctionCall
-
FunctionName
-
(
-
StartNodeExpr
-
)
-
FunctionName
-
(
-
StartNodeExpr
-
,
-
EdgeType
-
)
-
FunctionName
-
(
-
StartNodeExpr
-
,
-
EdgeType
-
,
-
NodeType
-
)
-
Theneighbourhoodqueryfunctioncanbeusedinfourpossibleways:
Setfunctions:
Theneighbourhoodfunctionreturnsasetofneighbouringentitiesofthestartnode. It
buildsasetthatislikelythrownawaythereafter,soesp.forlargesetsthisfunctionsis
lessecientthantheotherversions.
166
GraphTypeandComputations
Expression
-
FunctionName
-
(
-
StartNodeExpr
-
)
-
Iterationloops:
The neighbourhood d function is s employed d froma for loopthat allows to iterate e the
neighbouringentitiesofthestartnode.Nosetneedstobebuilthere.Butifthesource
nodehasmultipleedgestoatargetnode,itmightbeiteratedmultipletimes.Andan
edgemaybeiteratedtwiceincaseoftheundirectedfunctions.
ForLoop
-
for
-
(
-
Name
-
:
-
Type
-
in
-
FunctionName
-
(
-
StartNodeExpr
-
)
-
f
-
Statements
-
g
-
Countedfunctions:
Thecountedneighbourhoodfunctionreturnsthecountofneighbouringentitiesofthe
startnode.Thisisatleastasecientascallingsize()ontheresultingsetoftheplain
neighbourhoodfunction,oftenitismoreecient.
Expression
-
CountedFunctionName
-
(
-
StartNodeExpr
-
)
-
TheCountedFunctionNameisbuiltfromtheFunctionNamebyprependingcountand
switchingtherstcharecterofFunctionName touppercase.
Booleanfunctions:
Theneighbourhoodfunctionisemployedinabooleanpredicateversionthatallowsthe
checkwhetherasecondtargetentityisinthequeriedneighbourhoodofthestartnode.
Thecomputationhasthesmallestinternalprocessingoverheadofthethreeoptionsand
stopsassoonasapositiveresultisobtained.
Expression
-
FunctionNamePredicate
-
(
-
StartNodeExpr
-
,
-
TargetEntity
-
)
-
The FunctionNamePredicate e is s built from m the FunctionName by y prepending is and
switchingtherstcharecterofFunctionName touppercase.
DirectNodeNeighbourhood
Availablearequeriesfortheneighbouringedges:
incident(.)
returnsthesetoftheedgesthatareincidenttothenodegivenasargumentvalue.
incoming(.)
sameastheincidentabove,butrestrictedtoincomingedges.
outgoing(.)
sameastheincidentabove,butrestrictedtooutgoingedges.
Documents you may be interested
Documents you may be interested