c#,将程序更改为线性搜索

时间:2017-04-19 17:43:20

标签: c# replace linear-search

我几天前制作了这段代码并且有一个非常简单的问题。我知道这样的问题已被问到,但我找不到任何特别适用于我的案例。我想将案例3中的搜索功能更改为不太复杂的搜索方法,所以我基本上想用线性搜索替换它。如果那是不可能的,我想在其他地方实现线性搜索。你们有什么线索吗?感谢所有帮助。

<?php 
session_start();    

$_SESSION['name'] = "Adam"; 

?>

}

1 个答案:

答案 0 :(得分:1)

案例3中的关键字搜索已经是线性的。您是否只是想让搜索语句在交换机内更简洁?然后将搜索表达式转换为函数:

var entries = SearchByKeyword(loggbok, nyckelord);

并在switch语句中调用它:

library(shiny)
library(shinyjs)
library(shinyBS)

ui = fluidPage(
  useShinyjs(),
  sidebarLayout(
    sidebarPanel(HTML("This button will open Panel1 using <code>updateCollapse</code>."),
                 actionButton("p1Button", "Push Me!"),
                 selectInput("styleSelect", "Select style for Panel1",
                             c("default", "primary", "danger", "warning", "info", "success"))
    ),
    mainPanel(
      bsCollapse(id = "collapseExample", open = "Panel 2",
                 bsCollapsePanel("Panel1", "This is a panel with just text ",
                                 "and has the default style. You can change the style in ",
                                 "the sidebar.", style = "info", id = "me23")
      ),
      verbatimTextOutput('randomNumber')
    )
  )
)

server = function(input, output, session) {
  observeEvent(input$p1Button, ({
    updateCollapse(session, "collapseExample", open = "Panel1")
  }))
  observeEvent(input$styleSelect, ({
    updateCollapse(session, "collapseExample", style = list("Panel1" = input$styleSelect))
  }))

  observe({
    runjs("function getAllElementsWithAttribute(attribute){
              var matchingElements = [];
              var allElements = document.getElementsByTagName('*');
              for (var i = 0, n = allElements.length; i < n; i++)
              {
              if (allElements[i].getAttribute(attribute) !== null)
              {
              // Element exists with attribute. Add to array.
              matchingElements.push(allElements[i]);
              }
              }
              return matchingElements;
              };
              ahref = getAllElementsWithAttribute('data-toggle');
              ahref[0].onclick = function() { 
                var nmbr = Math.random();
                Shiny.onInputChange('randomNumber', nmbr);
              };
          ")
  })
  output$randomNumber <- reactive(paste0(input$randomNumber))
}




shinyApp(ui = ui, server = server)